--- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -220,7 +220,7 @@ end def image? - !!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png|webp)$/i) + !!(self.filename =~ /\.(bmp|gif|jpg|jpe|jpeg|png|webp|heic|heif)$/i) end def thumbnailable? --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -999,7 +999,7 @@ if attachments.present? title_and_alt_re = /\s+(title|alt)="([^"]*)"/i - text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png|webp))"([^>]*)/i) do |m| + text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png|webp|heic|heif))"([^>]*)/i) do |m| filename, ext, other_attrs = $1, $2, $3 # search for the picture in attachments --- a/lib/redmine/thumbnail.rb +++ b/lib/redmine/thumbnail.rb @@ -30,7 +30,7 @@ ('gswin64c' if Redmine::Platform.mswin?) || 'gs' ).freeze - ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png image/webp application/pdf) + ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png image/webp image/heic image/heif application/pdf) # Generates a thumbnail for the source image to target # TODO: Remove the deprecated _is_pdf parameter in Redmine 7.0 @@ -51,6 +51,8 @@ return nil unless valid_pdf_magic?(source) cmd = "#{shell_quote CONVERT_BIN} #{shell_quote "#{source}[0]"} -thumbnail #{shell_quote size_option} #{shell_quote "png:#{target}"}" + elsif mime_type == 'image/heic' || mime_type == 'image/heif' + cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -auto-orient -thumbnail #{shell_quote size_option} #{shell_quote "jpg:#{target}"}" else cmd = "#{shell_quote CONVERT_BIN} #{shell_quote source} -auto-orient -thumbnail #{shell_quote size_option} #{shell_quote target}" end --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -294,6 +294,9 @@ if is_thumb && content_type == "application/pdf" # PDF previews are stored in PNG format content_type = "image/png" + elsif is_thumb && (content_type == "image/heic" || content_type == "image/heif") + # HEIC/HEIF previews are stored in JPEG format + content_type = "image/jpeg" end content_type