Skip to content

[6.x] Fix Glide tag erroring when an asset cannot be resolved - #15360

Open
lazerg wants to merge 2 commits into
statamic:6.xfrom
lazerg:fix/issue-15359-glide-null-asset
Open

[6.x] Fix Glide tag erroring when an asset cannot be resolved#15360
lazerg wants to merge 2 commits into
statamic:6.xfrom
lazerg:fix/issue-15359-glide-null-asset

Conversation

@lazerg

@lazerg lazerg commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

When the Glide tag is given an asset that can't be resolved, the tag 500s the whole page instead of skipping the image. normalizeItem() returns null for an unresolvable asset ID, and that null then reaches ImageGenerator::generateByAsset(), which calls isVideo() on it, or Asset::find(), which rejects it against its string signature. Both are an \Error rather than an \Exception, so they slip past the catch (\Exception) in Glide::generate(). There are three ways to hit this today: the plain unresolvable ID, the same ID with fit="crop_focal", and the same ID when the cache disk has a URL so images are served directly.

Every other failure inside that closure degrades gracefully, so these should too. normalizeItem() now keeps the original ID when it can't resolve it, which is what it already does for the URL branch a few lines down, and generateImage() throws an AssetNotFoundException when there's still no asset. The existing catch logs it and the image is skipped. That mirrors the guard StaticUrlBuilder::generatePath() already has for the same situation.

Keeping the ID also cleans up the single tag form, {{ glide src="..." }} without a closing tag. That one only builds a URL, so it never crashed, but it was passing the null down into rawurlencode() and triggering a deprecation on the way to a /img?w=100 URL with no image in it.

Fixes #15359

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.

Glide tag 500s the whole page when an asset URL resolves to null (isVideo() on null)

1 participant