mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Restricts the list of file types that can be thumbnailed.
git-svn-id: http://svn.redmine.org/redmine/trunk@16092 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
18463cad4d
commit
f9823d1028
@ -23,13 +23,14 @@ module Redmine
|
||||
extend Redmine::Utils::Shell
|
||||
|
||||
CONVERT_BIN = (Redmine::Configuration['imagemagick_convert_command'] || 'convert').freeze
|
||||
ALLOWED_TYPES = %w(image/bmp image/gif image/jpeg image/png)
|
||||
|
||||
# Generates a thumbnail for the source image to target
|
||||
def self.generate(source, target, size)
|
||||
return nil unless convert_available?
|
||||
unless File.exists?(target)
|
||||
# Make sure we only invoke Imagemagick if this is actually an image
|
||||
unless File.open(source) {|f| MimeMagic.by_magic(f).try(:image?)}
|
||||
# Make sure we only invoke Imagemagick if the file type is allowed
|
||||
unless File.open(source) {|f| ALLOWED_TYPES.include? MimeMagic.by_magic(f).try(:type) }
|
||||
return nil
|
||||
end
|
||||
directory = File.dirname(target)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user