国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Jadual Kandungan
Automation
The SVG route
What about WordPress?
Rumah hujung hadapan web tutorial css Gambar media sosial yang dihasilkan secara automatik

Gambar media sosial yang dihasilkan secara automatik

Mar 24, 2025 am 09:37 AM

Auto-Generated Social Media Images

I’ve been thinking about social media images again. You know, the images that (can) show up when you share a link in places like Twitter, Facebook, or iMessage. You’re essentially leaving money on the table without them, because they turn a regular post with a little ol’ link in it into a post with a big honkin’ attention grabbin’ image on it, with a massive clickable area. Of any image on a website, the social media image might be the #1 most viewed, most remembered, most network-requested image on the site.

It’s essentially this bit of HTML that makes them happen:

<meta property="og:image" content="/images/social-media-image.jpg" />

But make sure to read up on it as there are a bunch other other HTML tags to get right.

I think I’m thinking about it again because GitHub seems to have new social media cards. These are new, right?

Those GitHub social media images are clearly programmatically generated. Check out an example URL.

Automation

While I think you can get a lot of bang out of a totally hand-crafted bespoke-designed social media image, that’s not practical for sites with lots of pages: blogs, eCommerce… you know what I mean. The trick for sites like that is to automate their creation via templating somehow. I’ve mentioned other people’s takes on this in the past, but let’s recap:

  • Drew McLellan: Dynamic Social Sharing Images
  • Vercel: Open Graph Image as a Service
  • Phil Hawksworth: social-image-generator
  • Ryan Filler: Automatic Social Share Images

You know what all those have in common? Puppeteer.

Puppeteer is a way to spin up and control a headless copy of Chrome. It has this incredibly useful feature of being able to take a screenshot of the browser window: await page.screenshot({path: 'screenshot.png'});. That’s how our coding fonts website does the screenshots. The screenshotting idea is what gets people’s minds going. Why not design a social media template in HTML and CSS, then ask Puppeteer to screenshot it, and use that as the social media image?

I love this idea, but it means having access to a Node server (Puppeteer runs on Node) that is either running all the time, or that you can hit as a serverless function. So it’s no wonder that this idea has resonated with the Jamstack crowd who are already used to doing things like running build processes and leveraging serverless functions.

I think the idea of “hosting” the serverless function at a URL?—?and passing it the dynamic values of what to include in the screenshot via URL parameter is also clever.

The SVG route

I kinda dig the idea of using SVG as the thing that you template for social media images, partially because it has such fixed coordinates to design inside of, which matches my mental model of making the exact dimensions you need to design social media images. I like how SVG is so composable.

George Francis blogged “Create Your Own Generative SVG Social Images” which is a wonderful example of all this coming together nicely, with a touch of randomization and whimsy. I like the contenteditable trick as well, making it a useful tool for one-off screenshotting.

I’ve dabbled in dynamic SVG creation as well: check out this conference page on our Conferences site.

Unfortunately, SVG isn’t a supported image format for social media images. Here’s Twitter specifically:

URL of image to use in the card. Images must be less than 5MB in size. JPG, PNG, WEBP and GIF formats are supported. Only the first frame of an animated GIF will be used. SVG is not supported.

Twitter docs

Still, composing/templating in SVG can be cool. You convert it to another format for final usage. Once you have an SVG, the conversion from SVG to PNG is almost trivially easy. In my case, I used svg2png and a very tiny Gulp task that runs during the build process.

What about WordPress?

I don’t have a build process for my WordPress site?—?at least not one that runs every time I publish or update a post. But WordPress would benefit the most (in my world) from dynamic social media images.

It’s not that I don’t have them now. Jetpack goes a long way in making this work nicely. It makes the “featured image” of the post the social media image, allows me to preview it, and auto-posts to social networks. Here’s a video I did on that. That’s gonna get me to a place where the featured images are attached and showing nicely.

But it doesn’t automate their creation. Sometimes a bespoke graphic alone is the way to go (the one above might be a good example of that), but perhaps more often a nicely templated card is the way to go.

Fortunately I caught wind of Social Image Generator for WordPress from Daniel Post. Look how fancy:

This is exactly what WordPress needs!

Daniel himself helped me create a custom template just for CSS-Tricks. I had big dreams of having a bunch of templates to choose from that incorporate the title, author, chosen quotes, featured images, and other things. So far, we’ve settled on just two, a template with the title and author, and a template with a featured image, title, and author. The images are created from that metadata on the fly:

This ain’t Puppeteer. This ain’t even the PhantomJS powered svgtopng. This is PHP generated images! And not even ImageMagick, but straight up GD, the thing built right into PHP. So these images are not created in any kind of syntax that would likely feel comfortable to a front-end developer. You’re probably better off using one of the templates, but if you wanna see how my custom one was coded (by Daniel), lemme know and I can post the code somewhere public.

Pretty cool result, right?

I get why it had to be built this way: it’s using technology that will work literally anywhere WordPress can run. That’s very much in the WordPress spirit. But it does make me wish creating the templates could be done in a more modern way. Like wouldn’t it be cool if the template for your social media images was just like social-image.php at the root of the theme like any other template file? And you template and design that page with all the normal WordPress APIs? Like an ACF Block almost? And it gets screenshot and used? I’ll answer for you: Yes, that would be cool.

Atas ialah kandungan terperinci Gambar media sosial yang dihasilkan secara automatik. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn

Alat AI Hot

Undress AI Tool

Undress AI Tool

Gambar buka pakaian secara percuma

Undresser.AI Undress

Undresser.AI Undress

Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover

AI Clothes Remover

Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Clothoff.io

Clothoff.io

Penyingkiran pakaian AI

Video Face Swap

Video Face Swap

Tukar muka dalam mana-mana video dengan mudah menggunakan alat tukar muka AI percuma kami!

Alat panas

Notepad++7.3.1

Notepad++7.3.1

Editor kod yang mudah digunakan dan percuma

SublimeText3 versi Cina

SublimeText3 versi Cina

Versi Cina, sangat mudah digunakan

Hantar Studio 13.0.1

Hantar Studio 13.0.1

Persekitaran pembangunan bersepadu PHP yang berkuasa

Dreamweaver CS6

Dreamweaver CS6

Alat pembangunan web visual

SublimeText3 versi Mac

SublimeText3 versi Mac

Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

Topik panas

Tutorial PHP
1488
72
Tutorial CSS untuk membuat pemuatan dan animasi pemuatan Tutorial CSS untuk membuat pemuatan dan animasi pemuatan Jul 07, 2025 am 12:07 AM

Terdapat tiga cara untuk membuat pemutar pemuatan CSS: 1. Gunakan pemutar asas sempadan untuk mencapai animasi mudah melalui HTML dan CSS; 2. Gunakan pemutar tersuai pelbagai mata untuk mencapai kesan lompat melalui masa kelewatan yang berlainan; 3. Tambahkan pemutar dalam butang dan beralih kelas melalui JavaScript untuk memaparkan status pemuatan. Setiap pendekatan menekankan pentingnya butiran reka bentuk seperti warna, saiz, kebolehcapaian dan pengoptimuman prestasi untuk meningkatkan pengalaman pengguna.

Menangani masalah dan awalan keserasian penyemak imbas CSS Menangani masalah dan awalan keserasian penyemak imbas CSS Jul 07, 2025 am 01:44 AM

Untuk menangani keserasian pelayar CSS dan isu awalan, anda perlu memahami perbezaan sokongan penyemak imbas dan menggunakan awalan vendor dengan munasabah. 1. Memahami masalah biasa seperti Flexbox dan sokongan grid, kedudukan: prestasi tidak sah, dan prestasi animasi adalah berbeza; 2. Periksa status sokongan ciri CANIUSE Ciri; 3. Gunakan dengan betul -webkit-, -moz-, -ms-, -o- dan awalan pengeluar lain; 4. Adalah disyorkan untuk menggunakan autoprefixer untuk menambah awalan secara automatik; 5. Pasang postcss dan konfigurasi penyemak imbas untuk menentukan penyemak imbas sasaran; 6. Secara automatik mengendalikan keserasian semasa pembinaan; 7. Ciri -ciri pengesanan moden boleh digunakan untuk projek lama; 8. Tidak perlu meneruskan konsistensi semua pelayar,

Apakah perbezaan antara paparan: inline, paparan: blok, dan paparan: blok sebaris? Apakah perbezaan antara paparan: inline, paparan: blok, dan paparan: blok sebaris? Jul 11, 2025 am 03:25 AM

Themaindifferencesbetweendisplay: inline, block, andinline-blockinhtml/cssarelayoutbehavior, spaceusage, andstylingcontrol.1.inlineelementsflowwithtext, notstartonNewlines, abaikanwidth/height, andonyapplylylylylylinddding/

Membuat bentuk tersuai dengan laluan klip CSS Membuat bentuk tersuai dengan laluan klip CSS Jul 09, 2025 am 01:29 AM

Gunakan atribut clip-path CSS untuk menanam unsur-unsur ke dalam bentuk tersuai, seperti segitiga, takik bulat, poligon, dan lain-lain, tanpa bergantung pada gambar atau SVG. Kelebihannya termasuk: 1. Menyokong pelbagai bentuk asas seperti Circle, Ellipse, Polygon, dan lain -lain; 2. Pelarasan responsif dan boleh disesuaikan dengan terminal mudah alih; 3. Mudah untuk animasi, dan boleh digabungkan dengan hover atau javascript untuk mencapai kesan dinamik; 4. Ia tidak menjejaskan aliran susun atur, dan hanya tanaman kawasan paparan. Penggunaan umum adalah seperti laluan klip bulat: bulatan (50pxatcenter) dan triangle clip-path: polygon (50%0%, 100 0%, 0 0%). Notis

Gaya yang dikunjungi pautan berbeza dengan CSS Gaya yang dikunjungi pautan berbeza dengan CSS Jul 11, 2025 am 03:26 AM

Menetapkan gaya pautan yang telah anda lawati dapat meningkatkan pengalaman pengguna, terutama di laman web yang berintensifkan kandungan untuk membantu pengguna menavigasi lebih baik. 1. Gunakan CSS: Kelas pseudo yang dilawati untuk menentukan gaya pautan yang dikunjungi, seperti perubahan warna; 2. Perhatikan bahawa penyemak imbas hanya membenarkan pengubahsuaian beberapa atribut disebabkan oleh sekatan privasi; 3. Pemilihan warna harus diselaraskan dengan gaya keseluruhan untuk mengelakkan ketangkasan; 4. Terminal mudah alih mungkin tidak memaparkan kesan ini, dan disyorkan untuk menggabungkannya dengan arahan visual lain seperti logo tambahan ikon.

Bagaimana untuk membuat imej responsif menggunakan CSS? Bagaimana untuk membuat imej responsif menggunakan CSS? Jul 15, 2025 am 01:10 AM

Untuk membuat imej responsif menggunakan CSS, ia boleh dicapai terutamanya melalui kaedah berikut: 1. Gunakan maksimum lebar: 100% dan ketinggian: auto untuk membolehkan imej menyesuaikan diri dengan lebar kontena sambil mengekalkan perkadaran; 2. Gunakan atribut SRCSET dan saiz HTML dengan bijak memuatkan sumber imej yang disesuaikan dengan skrin yang berbeza; 3. Gunakan objek-sesuai dan kedudukan objek untuk mengawal penanaman imej dan paparan fokus. Bersama -sama, kaedah ini memastikan bahawa imej dibentangkan dengan jelas dan indah pada peranti yang berbeza.

Unit CSS Demystifying: PX, EM, REM, VW, VH Perbandingan Unit CSS Demystifying: PX, EM, REM, VW, VH Perbandingan Jul 08, 2025 am 02:16 AM

Pilihan unit CSS bergantung kepada keperluan reka bentuk dan keperluan responsif. 1.PX digunakan untuk saiz tetap, sesuai untuk kawalan yang tepat tetapi kekurangan keanjalan; 2.EM adalah unit relatif, yang mudah disebabkan oleh pengaruh unsur induk, sementara REM lebih stabil berdasarkan unsur akar dan sesuai untuk skala global; 3.VW/VH didasarkan pada saiz viewport, sesuai untuk reka bentuk yang responsif, tetapi perhatian harus dibayar kepada prestasi di bawah skrin yang melampau; 4. Apabila memilih, ia harus ditentukan berdasarkan sama ada pelarasan responsif, hubungan hierarki elemen dan ketergantungan viewport. Penggunaan yang munasabah boleh meningkatkan fleksibiliti dan penyelenggaraan susun atur.

Apakah ketidakkonsistenan penyemak imbas CSS biasa? Apakah ketidakkonsistenan penyemak imbas CSS biasa? Jul 26, 2025 am 07:04 AM

Penyemak imbas yang berbeza mempunyai perbezaan dalam parsing CSS, mengakibatkan kesan paparan yang tidak konsisten, terutamanya termasuk perbezaan gaya lalai, kaedah pengiraan model kotak, flexbox dan tahap sokongan susun atur grid, dan tingkah laku yang tidak konsisten bagi atribut CSS tertentu. 1. Pemprosesan gaya lalai tidak konsisten. Penyelesaiannya adalah menggunakan cssreset atau normalisasi.css untuk menyatukan gaya awal; 2. Kaedah pengiraan model kotak versi lama IE adalah berbeza. Adalah disyorkan untuk menggunakan kotak-kotak: kotak sempadan dengan cara yang bersatu; 3. Flexbox dan grid melakukan secara berbeza dalam kes kelebihan atau dalam versi lama. Lebih banyak ujian dan gunakan autoprefixer; 4. Beberapa tingkah laku atribut CSS tidak konsisten. CANIUSE mesti dirujuk dan diturunkan.

See all articles