A platform for community discussion. Free, open, simple.
DEV: Pass the is_image flag when triggering the before_upload_creation event (#10031)
Roman Rizzia4bfa3542070
diff --git a/lib/upload_creator.rb b/lib/upload_creator.rbindex 368569af446..caaacb0a748 100644--- a/lib/upload_creator.rb+++ b/lib/upload_creator.rb@@ -34,16 +34,14 @@ class UploadCreatorreturn @uploadend- DiscourseEvent.trigger(:before_upload_creation, @file)-- DistributedMutex.synchronize("upload_#{user_id}_#{@filename}") do- # test for image regardless of input- @image_info = FastImage.new(@file) rescue nil+ @image_info = FastImage.new(@file) rescue nil+ is_image = FileHelper.is_supported_image?(@filename)+ is_image ||= @image_info && FileHelper.is_supported_image?("test.#{@image_info.type}")+ is_image = false if @opts[:for_theme]- is_image = FileHelper.is_supported_image?(@filename)- is_image ||= @image_info && FileHelper.is_supported_image?("test.#{@image_info.type}")- is_image = false if @opts[:for_theme]+ DiscourseEvent.trigger(:before_upload_creation, @file, is_image)+ DistributedMutex.synchronize("upload_#{user_id}_#{@filename}") doif is_imageextract_image_info!return @upload if @upload.errors.present?