fix: avif images not converting to upload.formatOptions set file types (#11505)

Previously, AVIF images were not converted to other file types as
expected, despite `upload.formatOptions` specifying a different file
type.

The issue was due to `canResizeImage` not recognizing `'image/avif',`
causing `fileSupportsResize` to return `false` and preventing the image
from undergoing format conversion.

This fix updates `canResizeImage` to include `'image/avif'`, ensuring
that AVIF images are processed correctly and converted to a different
file type when specified in `formatOptions`.

Fixes #10694 
Fixes #9985
This commit is contained in:
Patrik
2025-03-03 14:58:39 -05:00
committed by GitHub
parent efce1549d0
commit c417e3a627
3 changed files with 18 additions and 1 deletions

View File

@@ -1,3 +1,7 @@
export function canResizeImage(mimeType: string): boolean { export function canResizeImage(mimeType: string): boolean {
return ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/tiff'].indexOf(mimeType) > -1 return (
['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/tiff', 'image/avif'].indexOf(
mimeType,
) > -1
)
} }

View File

@@ -223,6 +223,19 @@ describe('Uploads', () => {
await saveDocAndAssert(page) await saveDocAndAssert(page)
}) })
test('should properly convert avif image to png', async () => {
await page.goto(mediaURL.create)
await page.setInputFiles('input[type="file"]', path.resolve(dirname, './test-image-avif.avif'))
const filename = page.locator('.file-field__filename')
await expect(filename).toHaveValue('test-image-avif.avif')
await saveDocAndAssert(page)
const fileMetaSizeType = page.locator('.file-meta__size-type')
await expect(fileMetaSizeType).toHaveText(/image\/png/)
})
test('should create animated file upload', async () => { test('should create animated file upload', async () => {
await page.goto(animatedTypeMediaURL.create) await page.goto(animatedTypeMediaURL.create)

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B