MediaUpload, Settings: Add option to always convert to jpeg.

This commit is contained in:
Lain Soykaf 2025-01-29 18:09:13 +04:00
commit 02c5ee9c49
5 changed files with 15 additions and 4 deletions

View file

@ -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