Defect #32289

Don't try to generate thumbnails if convert command is not available

Added by Go MAEDA about 1 month ago. Updated 19 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Attachments
Target version:4.1.0
Resolution:Fixed Affected version:

Description

Currently, Redmine always tries to render attachment thumbnails if the setting "Display attachment thumbnails" is enabled even when ImageMagick's convert command is not available. As a result, users may see broken image icons.

I think such broken things should not be displayed. Redmine should not try to generate thumbnails if the command to create thumbnails is not available.

broken-image-icon@2x.png (171 KB) Go MAEDA, 2019-10-16 08:15

32289_not_thumbnailable_when_convert_unavailable.patch Magnifier (1.24 KB) Yuichi HARADA, 2019-10-28 08:58

32289-v2.patch Magnifier (1.24 KB) Go MAEDA, 2019-10-30 16:02


Related issues

Blocks Redmine - Feature #32249: Show attachment thumbnails by default Closed

Associated revisions

Revision 18885
Added by Go MAEDA 19 days ago

Don't try to generate thumbnails if convert command is not available (#32289).

Patch by Go MAEDA.

History

#1 Updated by Go MAEDA about 1 month ago

#2 Updated by Yuichi HARADA 22 days ago

The following patch will determine if ImageMagick's convert command is available. I attached a patch.

diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 8304d4dea..627c1a181 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -201,7 +201,9 @@ class Attachment < ActiveRecord::Base
   end

   def thumbnailable?
-    image? || (is_pdf? && Redmine::Thumbnail.gs_available?)
+    Redmine::Thumbnail.convert_available? && (
+      image? || (is_pdf? && Redmine::Thumbnail.gs_available?)
+    )
   end

   # Returns the full path the attachment thumbnail, or nil

#3 Updated by Go MAEDA 20 days ago

  • Target version set to Candidate for next major release

#4 Updated by Go MAEDA 19 days ago

  • File 32289-v2.patchMagnifier added
  • Assignee set to Go MAEDA
  • Target version changed from Candidate for next major release to 4.1.0

LGTM. Updated the test name.

Setting the target version to 4.1.0.

#5 Updated by Go MAEDA 19 days ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Committed the patch.

Also available in: Atom PDF