Skip to content

[6.x] Map the jpeg Glide format to jpg - #15932

Merged
duncanmcclean merged 2 commits into
statamic:6.xfrom
lwekuiper:fix/6.x-glide-jpeg-format
Nov 17, 2026
Merged

duncanmcclean merged 2 commits into
statamic:6.xfrom
lwekuiper:fix/6.x-glide-jpeg-format

Conversation

@lwekuiper

@lwekuiper lwekuiper commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Since Glide 4, passing fm=jpeg throws Invalid format provided: jpeg. Glide only knows the JPEG format as jpg. Glide 3 quietly fell back to jpg for formats it didn't know, so this went unnoticed until Glide 4 support landed in #15019.

This breaks {{ glide:image fm="jpeg" }}, presets with fm: jpeg (including a container's source preset, where the upload itself fails) and any addon that passes a file extension as the format. Peak's picture tag does that for its fallback image, so a page showing a .jpeg upload returns a 500 (studio1902/statamic-peak-tools#43).

This PR maps jpeg (case-insensitive) to jpg in GlideManager::normalizeParameters(), which presets already go through, and has ImageGenerator::setParams() use it too, so tag and URL params share the same rule. It's the same kind of normalization #14134 added for pjpg.

@duncanmcclean duncanmcclean left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I think the mapping would be better off in GlideManager::normalizeParameters() than in ImageGenerator::setParams().

Manipulation presets never go through setParams(). They're normalised by Manager::normalizePreset() (which calls Glide::normalizeParameters()) and then handed straight to the Glide server, which merges them in itself. So with this as it is, a preset with fm: jpeg would still throw Invalid format provided: jpeg on Glide 4. That applies whether the preset is used via {{ glide preset="..." }}, as a container's source preset (where Uploader calls makeImage() directly, so the upload itself would fail), or when presets are warmed on upload.

Could you:

  • Move the jpeg → jpg mapping into GlideManager::normalizeParameters(), alongside the existing format → fm aliasing (strtolower() the value so JPEG is covered too).
  • Have ImageGenerator::setParams() call Glide::normalizeParameters() instead of doing its own check, so tag/URL params and presets share one rule.
  • Add a test for a preset with fm: jpeg.

Thanks!

@lwekuiper

Copy link
Copy Markdown
Contributor Author

Good catch, thanks! The mapping now lives in GlideManager::normalizeParameters() (lowercased, so JPEG is covered too), setParams() calls it instead of its own check, and there's a test for a preset with fm: jpeg.

@duncanmcclean
duncanmcclean merged commit 8622147 into statamic:6.x Nov 17, 2026
62 checks passed
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.

2 participants