fix: image resize tiff files (#5449)
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
export default function canResizeImage(mimeType: string): boolean {
|
export default function canResizeImage(mimeType: string): boolean {
|
||||||
return ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].indexOf(mimeType) > -1
|
return ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/tiff'].indexOf(mimeType) > -1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export const generateFileData = async <T>({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isImage(file.mimetype)) {
|
if (fileSupportsResize || isImage(file.mimetype)) {
|
||||||
dimensions = getImageSize(file)
|
dimensions = getImageSize(file)
|
||||||
fileData.width = dimensions.width
|
fileData.width = dimensions.width
|
||||||
fileData.height = dimensions.height
|
fileData.height = dimensions.height
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export const useThumbnail = (
|
|||||||
return `${serverURL}/${thumbnailURL}`
|
return `${serverURL}/${thumbnailURL}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isImage(mimeType as string)) {
|
if (adminThumbnail || isImage(mimeType as string)) {
|
||||||
if (typeof adminThumbnail === 'undefined' && url) {
|
if (typeof adminThumbnail === 'undefined' && url) {
|
||||||
return url as string
|
return url as string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -287,6 +287,7 @@ export default buildConfigWithDefaults({
|
|||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
'image/gif',
|
'image/gif',
|
||||||
'image/svg+xml',
|
'image/svg+xml',
|
||||||
|
'image/tiff',
|
||||||
'audio/mpeg',
|
'audio/mpeg',
|
||||||
],
|
],
|
||||||
imageSizes: [
|
imageSizes: [
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { RESTClient } from '../helpers/rest.js'
|
|||||||
import { adminThumbnailSrc } from './collections/admin-thumbnail/RegisterThumbnailFn.js'
|
import { adminThumbnailSrc } from './collections/admin-thumbnail/RegisterThumbnailFn.js'
|
||||||
import config from './config.js'
|
import config from './config.js'
|
||||||
import { adminThumbnailSlug, audioSlug, mediaSlug, relationSlug } from './shared.js'
|
import { adminThumbnailSlug, audioSlug, mediaSlug, relationSlug } from './shared.js'
|
||||||
|
|
||||||
const filename = fileURLToPath(import.meta.url)
|
const filename = fileURLToPath(import.meta.url)
|
||||||
const dirname = path.dirname(filename)
|
const dirname = path.dirname(filename)
|
||||||
|
|
||||||
@@ -155,6 +156,17 @@ describe('uploads', () => {
|
|||||||
await expect(iconMeta).toContainText('16x16')
|
await expect(iconMeta).toContainText('16x16')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('should resize and show tiff images', async () => {
|
||||||
|
await page.goto(mediaURL.create)
|
||||||
|
await page.setInputFiles('input[type="file"]', path.resolve(dirname, './test-image.tiff'))
|
||||||
|
|
||||||
|
await expect(page.locator('.file-field__upload .thumbnail svg')).toBeVisible()
|
||||||
|
|
||||||
|
await saveDocAndAssert(page)
|
||||||
|
|
||||||
|
await expect(page.locator('.file-details img')).toBeVisible()
|
||||||
|
})
|
||||||
|
|
||||||
test('should show draft uploads in the relation list', async () => {
|
test('should show draft uploads in the relation list', async () => {
|
||||||
await page.goto(relationURL.list)
|
await page.goto(relationURL.list)
|
||||||
|
|
||||||
|
|||||||
BIN
test/uploads/test-image.tiff
Normal file
BIN
test/uploads/test-image.tiff
Normal file
Binary file not shown.
Reference in New Issue
Block a user