Skip to content

[6.x] Keep the uploaded extension when the source preset doesn't convert the file - #15972

Merged
jasonvarga merged 1 commit into
statamic:6.xfrom
brstreet2:fix/source-preset-gif-extension
Nov 19, 2026
Merged

jasonvarga merged 1 commit into
statamic:6.xfrom
brstreet2:fix/source-preset-gif-extension

Conversation

@brstreet2

Copy link
Copy Markdown
Contributor

Fixes #15971

When a container's source preset sets a format (fm), AssetUploader::getNewExtension() gives the upload that extension even when Uploader::processSourceFile() stored the original file instead. That happens for GIFs (always skipped), for files ImageValidator rejects, and when Glide throws while applying the preset.

For example, a GIF uploaded with an fm: webp source preset is saved as animation.webp containing GIF data. Glide then rejects it as does not actually appear to be a valid image, so the upload fails when presets are warmed on upload, and the asset can't be used with the glide tag.

processSourceFile() now records when it applied the preset, and getNewExtension() only changes the extension when it did.

Tests

Two new tests in AssetTest, each uploading into a container whose source preset sets fm: png:

  • a GIF upload
  • a JPEG upload where Glide throws

Without the change, both files are saved as .png. The existing source preset tests still pass.

I also checked it in a fresh Statamic 6.42 site with an fm: webp source preset: a JPEG upload is still saved as .webp, and a GIF upload stays .gif and works with the glide tag.

…e file

getNewExtension() gave an upload the source preset's format even when
processSourceFile() stored the original file instead: for GIFs, files
ImageValidator rejects, and when Glide throws. A GIF uploaded with an
fm: webp source preset was saved as .webp containing GIF data, which
Glide then rejects.

processSourceFile() now records when it applied the preset, and
getNewExtension() only changes the extension when it did.
@jasonvarga
jasonvarga merged commit 049a7e3 into statamic:6.x Nov 19, 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.

Source preset with a format renames GIFs without converting them

2 participants