Skip to content

Fall back when social image Glide fails - #660

Merged
duncanmcclean merged 6 commits into
statamic:7.xfrom
edalzell:fix/social-image-glide-fallback
Sep 7, 2026
Merged

Fall back when social image Glide fails#660
duncanmcclean merged 6 commits into
statamic:7.xfrom
edalzell:fix/social-image-glide-fallback

Conversation

@edalzell

@edalzell edalzell commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • When glide:generate can't produce a social image, fall back to the raw asset URL so og:image / twitter:image still render. This covers formats the configured image driver can't manipulate (e.g. SVG on GD) as well as files that fail to decode.
  • Adds a regression test covering both fallback reasons across the Antlers, Blade and Blade Components views.

Fixes #659

Test plan

  • Meta tags for a normal JPG social image still use Glide presets
  • SVG social image outputs og:image and twitter:image pointing at the raw asset (no /img/asset/ Glide URL)
  • Corrupt / undecodable raster social image outputs og:image and twitter:image pointing at the raw asset
  • vendor/bin/phpunit --filter='social_image'

Skip Glide for gif/svg OG and Twitter images, and use the raw asset URL when generate returns nothing so meta tags still render.
On Statamic 6.31, removing only the home entry still leaves findByUri('/') resolving to another page. Match 7.x and clear the pages collection instead.
@edalzell
edalzell force-pushed the fix/social-image-glide-fallback branch from 3afade8 to bcd0853 Compare September 6, 2026 20:30
@duncanmcclean
duncanmcclean changed the base branch from master to 7.x September 7, 2026 08:19
@duncanmcclean duncanmcclean reopened this Sep 7, 2026
duncanmcclean and others added 4 commits September 7, 2026 09:24
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012QLKhaM7gUc5BeDWysaYBG
evaluate `shouldGlideSocialImage()` once and make the new helpers `private`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012QLKhaM7gUc5BeDWysaYBG
the glide tag already returns the raw asset url for extensions the driver can't handle and drops items it fails to decode, so the template fallback covers both cases without a gif/svg allowlist in the tag.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012QLKhaM7gUc5BeDWysaYBG
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012QLKhaM7gUc5BeDWysaYBG
@duncanmcclean

Copy link
Copy Markdown
Member

Thanks for the PR. I've pushed up a handful of changes:

  • Retargeted the PR at 7.x and merged it in.
  • Removed the gif/svg allowlist from SeoProTags The glide:generate tag already returns the raw asset URL for formats the configured driver can't manipulate, and drops any item it fails to decode.
  • I couldn't replicate the GIF failure. Statamic pins league/glide ^3, which pulls Intervention 3.9, and that decodes and resizes animated gifs fine. The "Failed to decode GIF format" message in Social meta images fail (or disappear) when Glide cannot process the asset #659 doesn't exist in Intervention 3, so I suspect that was from a different setup.
  • Combined tests using a data provider covering various failure reasons.
  • Removed the site-localized fixture copies. Only MetaTagTest uses them, and it runs against the site fixture.

I'll merge and tag a release shortly.

@duncanmcclean
duncanmcclean merged commit 0c8b18c into statamic:7.x Sep 7, 2026
14 checks passed
@edalzell
edalzell deleted the fix/social-image-glide-fallback branch September 7, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Social meta images fail (or disappear) when Glide cannot process the asset

2 participants