Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module generates dynamic images for social media posts using tokens from your Drupal content, such as node titles or author names. These images can be used for meta tags or directly in your content.

This module automatically replaces image styles with a tokenized text overlay like [node:title] with a node's data, such as the title, the author or creation-date of the node, which can be used as a beautiful and meaningful image for social media.

You can use the generated image for example as image source for the og:image meta tag:
<meta property="og:image" content="http://domain.tld/my-dynamic-image.png"/>

Release 2.0.x

This realease introduces a major restructuring of the module to provide a more flexible and robust architecture for dynamic image generation. It is easier to setup and to use.

The new release uses Drupal core image-styles and the effect “Text overlay” from the “Image Effects”-module with “Tokens” to dynamically build the images. This eliminates the need to implement the image layout programmatically.

There is no upgrade path from 1.x to 2.x.

Usage:

  1. Create an image style with an text overlay effect from the Image-Effects-Module. The text can (and should) contain node-tokens like [node:title], which will be replaced by this module..
    Look inside the README.md for an example.
  2. Visit the Settings-Page: /admin/config/system/gsmi
  3. Select the node-types image-field (for example "field_seo_image") and your new image style.
  4. Use the following tokens (for example in the meta-tags) to output the full path for the node's generated image:
[node:generate-style] -> Image styled with current image-style and field from settings-page
[node:generate-style:STYLE_MACHINE_NAME] -> … styled with current image-style
[node:generate-style:STYLE_MACHINE_NAME:FIELD_MACHINE_NAME] -> … with current image-style and field

The node-tokens [node:title] will be replaced by the node's title. And that's the magic of this module!

Release 1.0.x

You can use the generated image for example as image source like:
src="generate-social-media-image/returnasimage/123"

Or as a source for the og:image meta tag:

Please note:

The image will be generated by your server every time someone or something hits the path. There is no caching!

Pro: The image could be created depending on varying data, like time, user, weather or my account balance. ;-)

Contra: It can slow down your server if the image is called very often and at the same time.
For this reason, you must explicitly give permission for users, if you want allow them to generate images on the fly:
/admin/people/permissions/module/gsmi

Features:

The modules functions are based on the GD library.
Currently, the following functions, among others, are implemented:

Automatically generate the image for node [nid] on every call:

/generate-social-media-image/returnasimage/[nid]

Generate the image for node [nid] and save it to a managed file:

/generate-social-media-image/savetofile/[nid]

Generate the image to node [nid], save it as a file and create a new media image element

/generate-social-media-image/savetofile/[nid]/true

Token, which outputs the full path for the nodes generated image:

[node:generated-image]

Installation:

See the documentation on how to install sandbox-modules:

Add repository to your composer.json

"repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        {
            "type": "vcs",
            "url": "https://git.drupalcode.org/project/gsmi.git"
        }
    ],

After that require the sandbox-module:
composer require drupal/gsmi:1.0.x-dev

Configuration:

You can change colors, fonts, sizes and source of the image at the configurations-page.
(Manage > Configuration > Media > Generate Social Media Image)
/admin/config/system/generate-social-media-image

At the end of the form, you can find a preview-image of your settings.

Don't forget to give permission to anyone who should be able to generate images!
/admin/people/permissions/module/gsmi

Can i create my own template for an automatic social media image?

Yes, you can: there is a hook_gsmi_imagelayout for that.

As an example and starting point on how to create your own template for an image, the module contains a sub-module "Generate Social Media Image (Example)" (gsmi_example).
You can switch the templates on the configurations-page.

Contact me if you need paid help in creating your own image template for social media.

Similar Modules:

Image Effects: "The Image Effects module provides a suite of additional image effects". Most of the layout-stuff can be done with this module and it is better suited if you need caching. But you cannot add variable data (like time, user-data, role, ...) to the generated image.
Image Generator: "This module generates an image on the fly from [url-]parameters.". If you don't need complex layouts, this module maybe will suit your needs, too.

Activity

Total releases
3
First release
Jan 2026
Latest release
6 days ago
Releases (12 mo)
3 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Release date
2.0.0-beta2 Pre-release Jul 11, 2026
2.0.0-beta1 Pre-release Jul 11, 2026
2.0.x-dev Dev Jan 24, 2026