MediaUpload, Settings: Add option to always convert to jpeg.
This commit is contained in:
parent
28a38d413d
commit
02c5ee9c49
5 changed files with 15 additions and 4 deletions
1
changelog.d/always-jpeg.add
Normal file
1
changelog.d/always-jpeg.add
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Added option to always convert images to JPEG format instead of using WebP when compressing images.
|
|
@ -76,9 +76,9 @@ const mediaUpload = {
|
||||||
const testCanvas = document.createElement('canvas')
|
const testCanvas = document.createElement('canvas')
|
||||||
const supportsWebP = testCanvas.toDataURL('image/webp').startsWith('data:image/webp')
|
const supportsWebP = testCanvas.toDataURL('image/webp').startsWith('data:image/webp')
|
||||||
|
|
||||||
// Convert to WebP if supported, otherwise JPEG
|
// Convert to WebP if supported and alwaysUseJpeg is false, otherwise JPEG
|
||||||
const type = supportsWebP ? 'image/webp' : 'image/jpeg'
|
const type = (!this.$store.getters.mergedConfig.alwaysUseJpeg && supportsWebP) ? 'image/webp' : 'image/jpeg'
|
||||||
const extension = supportsWebP ? '.webp' : '.jpg'
|
const extension = type === 'image/webp' ? '.webp' : '.jpg'
|
||||||
|
|
||||||
// Remove the original extension and add new one
|
// Remove the original extension and add new one
|
||||||
const newFileName = file.name.replace(/\.[^/.]+$/, '') + extension
|
const newFileName = file.name.replace(/\.[^/.]+$/, '') + extension
|
||||||
|
|
|
@ -269,6 +269,14 @@
|
||||||
{{ $t('settings.image_compression') }}
|
{{ $t('settings.image_compression') }}
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting
|
||||||
|
path="alwaysUseJpeg"
|
||||||
|
expert="1"
|
||||||
|
>
|
||||||
|
{{ $t('settings.always_use_jpeg') }}
|
||||||
|
</BooleanSetting>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<BooleanSetting
|
<BooleanSetting
|
||||||
path="useContainFit"
|
path="useContainFit"
|
||||||
|
|
|
@ -440,6 +440,7 @@
|
||||||
"attachmentRadius": "Attachments",
|
"attachmentRadius": "Attachments",
|
||||||
"attachments": "Attachments",
|
"attachments": "Attachments",
|
||||||
"image_compression": "Compress images before uploading",
|
"image_compression": "Compress images before uploading",
|
||||||
|
"always_use_jpeg": "Always convert images to JPEG format",
|
||||||
"avatar": "Avatar",
|
"avatar": "Avatar",
|
||||||
"avatarAltRadius": "Avatars (notifications)",
|
"avatarAltRadius": "Avatars (notifications)",
|
||||||
"avatarRadius": "Avatars",
|
"avatarRadius": "Avatars",
|
||||||
|
|
|
@ -194,7 +194,8 @@ export const defaultState = {
|
||||||
useAbsoluteTimeFormat: undefined, // instance default
|
useAbsoluteTimeFormat: undefined, // instance default
|
||||||
absoluteTimeFormatMinAge: undefined, // instance default
|
absoluteTimeFormatMinAge: undefined, // instance default
|
||||||
absoluteTime12h: undefined, // instance default
|
absoluteTime12h: undefined, // instance default
|
||||||
imageCompression: true
|
imageCompression: true,
|
||||||
|
alwaysUseJpeg: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// caching the instance default properties
|
// caching the instance default properties
|
||||||
|
|
Loading…
Add table
Reference in a new issue