mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FIX: do not treat TIFF, BMP, WEBP as images
Treating TIFF and BMP as images cause us to add them to IMG tags, this is very inconsistent across browsers. You can still upload these files they will simply not be displayed in IMG tags.
This commit is contained in:
@ -3,8 +3,6 @@ require_dependency "image_sizer"
|
||||
|
||||
class UploadCreator
|
||||
|
||||
TYPES_CONVERTED_TO_JPEG ||= %i{bmp png}
|
||||
|
||||
TYPES_TO_CROP ||= %w{avatar card_background custom_emoji profile_background}.each(&:freeze)
|
||||
|
||||
WHITELISTED_SVG_ELEMENTS ||= %w{
|
||||
@ -47,7 +45,7 @@ class UploadCreator
|
||||
if @image_info.type.to_s == "svg"
|
||||
whitelist_svg!
|
||||
elsif !Rails.env.test? || @opts[:force_optimize]
|
||||
convert_to_jpeg! if should_convert_to_jpeg?
|
||||
convert_to_jpeg! if convert_png_to_jpeg?
|
||||
downsize! if should_downsize?
|
||||
|
||||
return @upload if is_still_too_big?
|
||||
@ -158,8 +156,8 @@ class UploadCreator
|
||||
|
||||
MIN_PIXELS_TO_CONVERT_TO_JPEG ||= 1280 * 720
|
||||
|
||||
def should_convert_to_jpeg?
|
||||
return false if !TYPES_CONVERTED_TO_JPEG.include?(@image_info.type)
|
||||
def convert_png_to_jpeg?
|
||||
return false unless @image_info.type == :png
|
||||
return true if @opts[:pasted]
|
||||
return false if SiteSetting.png_to_jpg_quality == 100
|
||||
pixels > MIN_PIXELS_TO_CONVERT_TO_JPEG
|
||||
|
Reference in New Issue
Block a user