Adds a macro for inserting thumbnails in formatted text (#3510).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10013 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang committed 2012-07-16 17:15:40 +00:00
1 parent 5c2de4dfc9
commit 537be80be2
7 files changed
+79 -28

No files matched your search

+10 -2
View File
@@ -171,9 +171,17 @@ class Attachment < ActiveRecord::Base
# Returns the full path the attachment thumbnail, or nil
# if the thumbnail cannot be generated.
def thumbnail
def thumbnail(options={})
if thumbnailable? && readable?
size = Setting.thumbnails_size.to_i
size = options[:size].to_i
if size > 0
# Limit the number of thumbnails per image
size = (size / 50) * 50
# Maximum thumbnail size
size = 800 if size > 800
else
size = Setting.thumbnails_size.to_i
end
size = 100 unless size > 0
target = File.join(self.class.thumbnails_storage_path, "#{id}_#{digest}_#{size}.thumb")