Skip to content

Fix glide:data_url producing blank output during generation#220

Open
mynetx wants to merge 1 commit into
statamic:4.xfrom
mynetx:fix/glide-data-url-cache
Open

Fix glide:data_url producing blank output during generation#220
mynetx wants to merge 1 commit into
statamic:4.xfrom
mynetx:fix/glide-data-url-cache

Conversation

@mynetx

@mynetx mynetx commented Jul 4, 2026

Copy link
Copy Markdown

When running ssg:generate, the {{ glide:data_url }} tag outputs nothing and logs Unable to read file from location: …. It only appears to work when a stale copy of the image happens to be sitting in the local glide cache from previously browsing the site.

That's because bindGlide() points the Glide server's cache at the static output directory, so generated images get written there — but the tag reads the image back through Glide::cacheDisk(), which still points at the default storage/statamic/glide location. Write and read disagree, so the read fails.

This PR points the glide cache disk config at the same static output location, so anything reading generated images back finds them where the server wrote them.

With {{ glide:data_url src="/image.png" width="50" }} in a template:

<!-- before -->
<img src="">

<!-- after -->
<img src="data:image/png;base64,iVBORw0KGg…">

The same write/read mismatch is behind several older reports: the {{ glide }} tag pair reads image dimensions back through the same cache disk (via Attributes), so with an empty glide cache it errors out (#110, #91, #123) or returns wrong width/height (#148). Verified against this branch: a tag pair that renders width="0" height="0" on 4.x with an empty cache renders the correct dimensions with this fix.

Fixes #204
Fixes #91
Fixes #110
Fixes #123
Fixes #148

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant