mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Rename FileHelper.is_image? -> FileHelper.is_supported_image?.
This commit is contained in:
@@ -910,7 +910,7 @@ module Email
|
||||
end
|
||||
|
||||
def attachment_markdown(upload)
|
||||
if FileHelper.is_image?(upload.original_filename)
|
||||
if FileHelper.is_supported_image?(upload.original_filename)
|
||||
"<img src='#{upload.url}' width='#{upload.width}' height='#{upload.height}'>"
|
||||
else
|
||||
"<a class='attachment' href='#{upload.url}'>#{upload.original_filename}</a> (#{number_to_human_size(upload.filesize)})"
|
||||
|
||||
@@ -11,8 +11,8 @@ class FileHelper
|
||||
)
|
||||
end
|
||||
|
||||
def self.is_image?(filename)
|
||||
filename =~ images_regexp
|
||||
def self.is_supported_image?(filename)
|
||||
filename =~ supported_images_regexp
|
||||
end
|
||||
|
||||
class FakeIO
|
||||
@@ -104,8 +104,8 @@ class FileHelper
|
||||
@@supported_images ||= Set.new %w{jpg jpeg png gif tif tiff bmp svg webp ico}
|
||||
end
|
||||
|
||||
def self.images_regexp
|
||||
@@images_regexp ||= /\.(#{supported_images.to_a.join("|")})$/i
|
||||
def self.supported_images_regexp
|
||||
@@supported_images_regexp ||= /\.(#{supported_images.to_a.join("|")})$/i
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ module FileStore
|
||||
content_type: opts[:content_type].presence || MiniMime.lookup_by_filename(filename)&.content_type
|
||||
}
|
||||
# add a "content disposition" header for "attachments"
|
||||
options[:content_disposition] = "attachment; filename=\"#{filename}\"" unless FileHelper.is_image?(filename)
|
||||
options[:content_disposition] = "attachment; filename=\"#{filename}\"" unless FileHelper.is_supported_image?(filename)
|
||||
# if this fails, it will throw an exception
|
||||
path = @s3_helper.upload(file, path, options)
|
||||
# return the upload url
|
||||
|
||||
@@ -37,8 +37,8 @@ class UploadCreator
|
||||
# test for image regardless of input
|
||||
@image_info = FastImage.new(@file) rescue nil
|
||||
|
||||
is_image = FileHelper.is_image?(@filename)
|
||||
is_image ||= @image_info && FileHelper.is_image?("test.#{@image_info.type}")
|
||||
is_image = FileHelper.is_supported_image?(@filename)
|
||||
is_image ||= @image_info && FileHelper.is_supported_image?("test.#{@image_info.type}")
|
||||
|
||||
if is_image
|
||||
extract_image_info!
|
||||
|
||||
@@ -36,7 +36,7 @@ class UrlHelper
|
||||
|
||||
uri = URI.parse(url)
|
||||
filename = File.basename(uri.path)
|
||||
is_attachment = !FileHelper.is_image?(filename)
|
||||
is_attachment = !FileHelper.is_supported_image?(filename)
|
||||
|
||||
no_cdn = SiteSetting.login_required || SiteSetting.prevent_anons_from_downloading_files
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class Validators::UploadValidator < ActiveModel::Validator
|
||||
extension = File.extname(upload.original_filename)[1..-1] || ""
|
||||
|
||||
if is_authorized?(upload, extension)
|
||||
if FileHelper.is_image?(upload.original_filename)
|
||||
if FileHelper.is_supported_image?(upload.original_filename)
|
||||
authorized_image_extension(upload, extension)
|
||||
maximum_image_file_size(upload)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user