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:
@@ -1,3 +1,7 @@
|
||||
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
|
||||
)
|
||||
}
|
||||
|
||||
@@ -223,6 +223,19 @@ describe('Uploads', () => {
|
||||
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 () => {
|
||||
await page.goto(animatedTypeMediaURL.create)
|
||||
|
||||
|
||||
BIN
test/uploads/test-image-avif.avif
Normal file
BIN
test/uploads/test-image-avif.avif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 495 B |
Reference in New Issue
Block a user