Theme:

Checking social images before they go out with Umbraco Automate

Learn how to check Open Graph images in Umbraco with Umbraco Automate, catching overlapping text and empty fields before a page goes live.

Articles on a website usually have a field for the Open Graph image, also called the share image, but editors often leave it empty. The page then has no Open Graph image, or it falls back to a default that does not represent the article. Filling the field in properly means designing an image in Canva, then testing it with an Open Graph checker or by sharing the link on WhatsApp to see if it renders correctly.

I wanted each article to get its own image automatically when it was published. I mentioned this to Paul Seal on a Teams call, and he told me he had been building a package that did exactly that, called Umbraco.Community.DynamicImages. So I installed it, configured it, published an article, and the share image was already sitting in the SEO tab.

The Dynamic Images designer showing the Article OG image template with its layers and a live preview

The Article OG image template in the Dynamic Images designer

The package comes with its own designer. It works in layers, a bit like Canva, and I was surprised how much it does. Each layer binds to a field on the page, and you can upload your own fonts, add shapes and preview against a real page before you save. Each design is called a template, and a Usage tab lists the pages using one and flags any with no image.

The Usage tab listing the pages that use the template, with the pages that have no image flagged

Usage shows at a glance which articles still have no share image

Getting started

I installed the package on an Umbraco 17 site with the Clean Starter Kit:


dotnet add package Umbraco.Community.DynamicImages

In the backoffice, give your user group access to the Dynamic Images section, add a font, then create a Dynamic Images template. In its Settings tab, pick the document types it applies to, and the media picker property on them that it fills (add that property to the document type first if it doesn't have one).

The template's Settings tab with the Article document type and the Social Share Image property selected

A template's Settings tab, set to Article and the Social Share Image property

Checking the image before it goes out

I also wanted a person to look at the image before it went out, but only when it needed it. With the Shrink to fit option on a template, a very long title is shown in smaller text so that it fits, and in my template a subtitle with no fixed width could run into the author's photo. Once a link is shared on a social media platform, its preview is sometimes cached, so a check beforehand is worth having.

Then I remembered Umbraco Automate. In Automate, a trigger such as a publish starts an automation, which runs a series of actions and can wait for a person to approve. That was what I needed: react to a publish event, check the image for overlapping text and empty template fields, and ask a person to approve it only when something looked wrong. The Codegarden 2026 demo shows it in action.

Writing the custom actions

I wrote two Automate actions on top of the package's services: Check Dynamic Image and Generate Dynamic Image. I call them Check and Generate from here on.

The Automate Select Action panel, filtered by the word Dynamic, listing Check Dynamic Image and Generate Dynamic Image in the Dynamic Images group

The two custom actions in the Automate action picker, under the Dynamic Images group

Before wiring them up, I changed two settings on my Dynamic Images template. I switched off its On publish toggle, so publishing no longer draws the image by itself, and I swapped the title's Shrink to fit for trimming with an ellipsis after three lines. The trimming is deliberate. A shrunk title leaves nothing for Check to find, but a trimmed one can be detected and flagged.

The When to run card in the template's Settings tab, with the On publish toggle switched off

The template's On publish toggle, switched off

The Title layer selected in the designer, with Max lines set to 3 and When it overflows set to Trim with an ellipsis

The title layer's Max lines and When it overflows settings

Check Dynamic Image works out where every layer of the template would land on the page, without drawing anything, using the package's MeasureLayoutAsync. It looks for text that was cut short, text running into other text or a photo, and layers that would be missing.

It reports what it found through outcomes, new in Automate 17.6.0. Each outcome becomes its own exit on the automation canvas, so the automation can take a different path depending on the result.

Both actions take a Template alias, which says which template to use. Leave it empty and they use the first enabled one for the page's document type.

I put the two actions together in an automation I called Share image pre-flight. Between them I used two of Automate's built-in actions: Notify Editor shows the warning toast, and Request Approval waits for a person to decide.

The Share image pre-flight automation canvas, with numbered steps from the Content Published trigger through Check, Notify Editor, Request Approval and Generate

The Share image pre-flight automation, with one exit for each outcome of Check

Check has to make sure none of the template's layers run into each other, and overlaps took me the longest to get right. Comparing layout boxes did not work, because the author's name sits in a 960-pixel box whether it says "John Doe" or something three times as long. In the end Check measures each glyph with the same font and wrapping the renderer uses.

The settings of the Check Dynamic Image step, with the overlap options highlighted

The Check Dynamic Image step's settings, with the overlap options highlighted

Once a page has passed Check, Generate Dynamic Image calls the package's RegenerateDocumentAsync, which draws the image, saves it to the page and publishes it.


[Action("dynamicImages.generate", "Generate Dynamic Image", Group = "Dynamic Images")]
public sealed class GenerateDynamicImageAction
    : ActionBase<GenerateDynamicImageSettings, GenerateDynamicImageOutput>
{
    public override async Task<ActionResult> ExecuteAsync(ActionContext context, CancellationToken cancellationToken)
    {
        var settings = context.GetSettings<GenerateDynamicImageSettings>();
        // ...find the page and its template...

        var result = await regeneration.RegenerateDocumentAsync(
            contentKey, template, force: true, allowPublish: settings.Publish, cancellationToken: cancellationToken);

        // ...pick the outcome from the result...
    }
}

The full code is in the demo repo on GitHub.

Hitting publish

With both actions in place, a Content Published trigger starts a run of the automation whenever an editor publishes an article. The Check step measures the image, and if it is clean, the Generate step draws it and saves it to the page a moment later. If something is wrong, the editor gets a toast listing the problems while they still have the page open, and the run waits in the Automation section, under Approvals, until someone decides. Approving sends it on to the Generate step, and rejecting ends the run with the page's old image left alone.

Publishing Santa's article

Let's see it in action. Since this is going out in December, the demo site's author is Santa Claus and I gave the template a Christmas background. I published one of his posts, "Moving the North Pole Gift Tracker to Umbraco 17: Lessons From Six Weeks", with the subtitle "How we moved two million wish lists off a spreadsheet in six weeks". The warning toast popped up:

A warning toast in the backoffice listing the problems found with the share image

The warning toast shown to the editor in the open document

The approval was waiting in the Automation section, under Approvals:

The Approvals tab in the Automation section, with one pending request

The Approvals tab under Automation, listing the request

The approval request dialog listing the problems the check found, with Reject and Approve buttons

The approval request, listing the problems the check found, with Reject and Approve buttons

This is the card that would have gone out:

A share image where the subtitle text runs underneath the author's photo

The share image with the subtitle running under Santa's photo

A subtitle running under the author's photo is not something to approve, so I rejected it and nothing was published. I shortened the subtitle to "Two million wish lists, one migration" and published again. This time Check only complained about the trimmed title. The full title is on the page anyway, so I approved it and the run published the image.

The Runs tab in the Automation section, showing a rejected run followed by a completed run

The runs list, with the rejected run followed by the completed one

Here is the image it published, with each layer named:

The published share image for Santa's article, with its Title, Name, Subtitle, ArticleDate and Image layers labelled

The published share image, with each layer named

Avoiding an infinite loop

Generate publishes the page, which raises Content Published again, and I was braced for an infinite loop. Setting the trigger's When triggered by another automation option to Skip entirely ignores any publish that comes from an automation, custom actions included, so one publish by an editor always gave me exactly one run. It does mean every edit now makes two publishes, and anything else listening to Content Published hears both.

The Content Published trigger settings, with When triggered by another automation set to Skip entirely

The trigger's setting that skips publishes made by another automation

Bonus: a 24days template

This article is going out on 24 Days in Umbraco, so the repo has a 24days template too, in the 24 Days site's dark blue, purple and green.

The 24days template in the Dynamic Images designer, in the 24 Days dark blue, purple and green

The 24days template in the designer

To use it, set Template alias to twentyFourDaysOgImage on both steps.

Run the demo site

Clone the demo repo and run the AutomateDynamicImages.Blog project. On the first launch Umbraco installs itself and seeds the demo data: the articles, the three templates, the fonts and the Share image pre-flight automation.


dotnet run --project AutomateDynamicImages.Blog --launch-profile Umbraco.Web.UI

Open https://localhost:44343/umbraco and log in with admin@example.com and 1234567890. Publish an article and watch the run under the Automation section.

Taking it further

I hope this gives you a few ideas of your own for Umbraco Automate and Dynamic Images. Automate lets you write your own actions, so you can build on what a package already does or turn your own idea into a step.

Thank you to Paul Seal for the package and for letting me loose on it, and to the 24 Days in Umbraco team for the opportunity to share it. Wishing you a wonderful Christmas in advance, and happy automating! 🎄✨

Photo credits: the baubles background is by Shamblen Studios and the photo of Santa is by Vitaly Gariev, both on Unsplash.


Skrift Gold: Implementing a CI/CD Workflow Using GitHub Actions

Check it out here