commit: 02c5ee9c495d06bc296d802f52b634489d3a3dd4
parent 28a38d413de0937c22f479fe50c96acf02f217bf
Author: Lain Soykaf <lain@lain.com>
Date: Wed, 29 Jan 2025 18:09:13 +0400
MediaUpload, Settings: Add option to always convert to jpeg.
Diffstat:
5 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/changelog.d/always-jpeg.add b/changelog.d/always-jpeg.add
@@ -0,0 +1 @@
+Added option to always convert images to JPEG format instead of using WebP when compressing images.
+\ No newline at end of file
diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js
@@ -76,9 +76,9 @@ const mediaUpload = {
const testCanvas = document.createElement('canvas')
const supportsWebP = testCanvas.toDataURL('image/webp').startsWith('data:image/webp')
- // Convert to WebP if supported, otherwise JPEG
- const type = supportsWebP ? 'image/webp' : 'image/jpeg'
- const extension = supportsWebP ? '.webp' : '.jpg'
+ // Convert to WebP if supported and alwaysUseJpeg is false, otherwise JPEG
+ const type = (!this.$store.getters.mergedConfig.alwaysUseJpeg && supportsWebP) ? 'image/webp' : 'image/jpeg'
+ const extension = type === 'image/webp' ? '.webp' : '.jpg'
// Remove the original extension and add new one
const newFileName = file.name.replace(/\.[^/.]+$/, '') + extension
diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue
@@ -271,6 +271,14 @@
</li>
<li>
<BooleanSetting
+ path="alwaysUseJpeg"
+ expert="1"
+ >
+ {{ $t('settings.always_use_jpeg') }}
+ </BooleanSetting>
+ </li>
+ <li>
+ <BooleanSetting
path="useContainFit"
expert="1"
>
diff --git a/src/i18n/en.json b/src/i18n/en.json
@@ -440,6 +440,7 @@
"attachmentRadius": "Attachments",
"attachments": "Attachments",
"image_compression": "Compress images before uploading",
+ "always_use_jpeg": "Always convert images to JPEG format",
"avatar": "Avatar",
"avatarAltRadius": "Avatars (notifications)",
"avatarRadius": "Avatars",
diff --git a/src/modules/config.js b/src/modules/config.js
@@ -194,7 +194,8 @@ export const defaultState = {
useAbsoluteTimeFormat: undefined, // instance default
absoluteTimeFormatMinAge: undefined, // instance default
absoluteTime12h: undefined, // instance default
- imageCompression: true
+ imageCompression: true,
+ alwaysUseJpeg: false
}
// caching the instance default properties