Repository navigation
[6.x] Map the jpeg Glide format to jpg - #15932
Conversation
duncanmcclean
left a comment
There was a problem hiding this comment.
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→jpgmapping intoGlideManager::normalizeParameters(), alongside the existingformat→fmaliasing (strtolower()the value soJPEGis covered too). - Have
ImageGenerator::setParams()callGlide::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!
|
Good catch, thanks! The mapping now lives in |
Since Glide 4, passing
fm=jpegthrowsInvalid format provided: jpeg. Glide only knows the JPEG format asjpg. Glide 3 quietly fell back tojpgfor formats it didn't know, so this went unnoticed until Glide 4 support landed in #15019.This breaks
{{ glide:image fm="jpeg" }}, presets withfm: 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.jpegupload returns a 500 (studio1902/statamic-peak-tools#43).This PR maps
jpeg(case-insensitive) tojpginGlideManager::normalizeParameters(), which presets already go through, and hasImageGenerator::setParams()use it too, so tag and URL params share the same rule. It's the same kind of normalization #14134 added forpjpg.