FEATURE: new 'convert_pasted_images_to_hq_jpg' site setting

This commit is contained in:
Régis Hanol
2016-07-25 23:01:28 +02:00
parent ece4fa82c9
commit 749b981759
3 changed files with 12 additions and 0 deletions

View File

@ -70,6 +70,15 @@ class UploadsController < ApplicationController
return { errors: I18n.t("upload.file_missing") } if tempfile.nil?
# convert pasted images to HQ jpegs
if filename == "blob.png" && SiteSetting.convert_pasted_images_to_hq_jpg
filename = "blob.jpg"
jpeg_path = "#{File.dirname(tempfile.path)}/#{filename}"
content_type = "image/jpeg"
`convert #{tempfile.path} -quality 95 #{jpeg_path}`
tempfile = File.open(jpeg_path)
end
# allow users to upload large images that will be automatically reduced to allowed size
max_image_size_kb = SiteSetting.max_image_size_kb.kilobytes
if max_image_size_kb > 0 && FileHelper.is_image?(filename)