Patch #13688 » 0001-makes-sure-the-generated-thumbnail-is-always-of-at-l.patch
| app/models/attachment.rb | ||
|---|---|---|
| 209 | 209 |
size = options[:size].to_i |
| 210 | 210 |
if size > 0 |
| 211 | 211 |
# Limit the number of thumbnails per image |
| 212 |
size = (size / 50) * 50
|
|
| 212 |
size = (size / 50.0).ceil * 50
|
|
| 213 | 213 |
# Maximum thumbnail size |
| 214 | 214 |
size = 800 if size > 800 |
| 215 | 215 |
else |
| test/unit/attachment_test.rb | ||
|---|---|---|
| 440 | 440 |
attachment = Attachment.find(16) |
| 441 | 441 |
assert_nil attachment.thumbnail |
| 442 | 442 |
end |
| 443 | ||
| 444 |
def test_thumbnail_should_be_at_least_of_requested_size |
|
| 445 |
set_fixtures_attachments_directory |
|
| 446 |
attachment = Attachment.find(16) |
|
| 447 |
Attachment.clear_thumbnails |
|
| 448 |
[ |
|
| 449 |
[0, 100], |
|
| 450 |
[49, 50], |
|
| 451 |
[50, 50], |
|
| 452 |
[51, 100], |
|
| 453 |
[100, 100], |
|
| 454 |
[101, 150], |
|
| 455 |
].each do |size, generated_size| |
|
| 456 |
thumbnail = attachment.thumbnail(size: size) |
|
| 457 |
assert_equal "16_8e0294de2441577c529f170b6fb8f638_#{generated_size}.thumb",
|
|
| 458 |
File.basename(thumbnail) |
|
| 459 |
end |
|
| 460 |
end |
|
| 443 | 461 |
else |
| 444 | 462 |
puts '(ImageMagick convert not available)' |
| 445 | 463 |
end |
- « Previous
- 1
- 2
- Next »