Patch #13688 » 0001-makes-sure-the-generated-thumbnail-is-always-of-at-l.patch
| app/models/attachment.rb | ||
|---|---|---|
|
size = options[:size].to_i
|
||
|
if size > 0
|
||
|
# Limit the number of thumbnails per image
|
||
|
size = (size / 50) * 50
|
||
|
size = (size / 50.0).ceil * 50
|
||
|
# Maximum thumbnail size
|
||
|
size = 800 if size > 800
|
||
|
else
|
||
| test/unit/attachment_test.rb | ||
|---|---|---|
|
attachment = Attachment.find(16)
|
||
|
assert_nil attachment.thumbnail
|
||
|
end
|
||
|
def test_thumbnail_should_be_at_least_of_requested_size
|
||
|
set_fixtures_attachments_directory
|
||
|
attachment = Attachment.find(16)
|
||
|
Attachment.clear_thumbnails
|
||
|
[
|
||
|
[0, 100],
|
||
|
[49, 50],
|
||
|
[50, 50],
|
||
|
[51, 100],
|
||
|
[100, 100],
|
||
|
[101, 150],
|
||
|
].each do |size, generated_size|
|
||
|
thumbnail = attachment.thumbnail(size: size)
|
||
|
assert_equal "16_8e0294de2441577c529f170b6fb8f638_#{generated_size}.thumb",
|
||
|
File.basename(thumbnail)
|
||
|
end
|
||
|
end
|
||
|
else
|
||
|
puts '(ImageMagick convert not available)'
|
||
|
end
|
||
- « Previous
- 1
- 2
- Next »