Share images for every entry, drawn by PHP when you save. No screenshot service, no Chrome, no API key.

Postcard Main Screenshot

Postcard draws a 1200 x 630 share image for your entries with PHP's own GD library. No screenshot service, no Chrome, no API key, no account anywhere else. The picture is made when you save an entry and stored as an ordinary asset.

It needs Statamic 6, PHP 8.2 or newer and the GD extension with FreeType (most hosts have it; php -m | grep gd shows it).

Install

  1. Add the package with Composer:

    composer require urgesta/postcard
  2. Optional: copy the config file to your site.

    php artisan vendor:publish --tag=postcard-config
  3. Open the control panel, go to Tools, Addons, Postcard, and pick the collections that should get an image on the Where tab. Save.

  4. Set your site's full address (for example https://example.com) in Settings, Site, or in resources/sites.yaml. The image tags print absolute URLs, so they need it.

  5. Draw images for the entries you already have:

    php please postcard:generate

    Add --collection=blog to do one collection only. From now on an image is drawn or refreshed every time you save an entry in a chosen collection.

Print the tags

In your layout, inside <head>:

Antlers:

{{ postcard:meta }}

Blade:

<x-postcard-meta :id="$id" />

Both print these tags for the current entry (nothing at all if that entry has no image yet):

<meta property="og:image" content="https://example.com/assets/postcard/blog/ENTRY-ID.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://example.com/assets/postcard/blog/ENTRY-ID.png">

To print the tags for another entry, pass its id: {{ postcard:meta id="..." }}.

Settings

Everything is on the Postcard settings page in the control panel:

  • Design: background colour, text colour, title size, site name size, site name, a logo (an asset), and the handle of the field on your entries that holds a picture. That picture is drawn on the right of the image.
  • Where: the collections that get an image, and whether drafts are skipped.
  • Preview: a sample image drawn from the saved settings. Save, then reload to see a change.

The same values can be set in config/postcard.php. Values saved in the control panel win over the config file. The config file also has the asset container (default assets) and the folder inside it (default postcard).

Titles shrink from your title size down to a minimum and then end with an ellipsis, so a very long title never runs off the image. A missing or unreadable picture or logo is skipped, not an error.

SEO Pro

Postcard does not change your entries, and it does not talk to SEO Pro. If SEO Pro prints your share tags, do not also print {{ postcard:meta }}, or the page will have two sets. Instead, point the image in SEO Pro at the asset that Postcard made: it is in the container and folder above, at postcard/COLLECTION/ENTRY-ID.png.

Where the files go

Images are saved to postcard/<collection handle>/<entry id>.png in the asset container you chose. The name does not change when you change the title, so the address stays the same and a re-save just replaces the file.

Licence

One licence covers one Statamic site. See LICENSE.md. The bundled Inter font is under the SIL Open Font License (resources/fonts/OFL.txt).