Commit 475bffcefaff98313cf4e833ce7e01b3d60dbc19
1 parent
f8efe666
Exists in
master
and in
22 other branches
ActionItem927: fixing resize of image on folder
Showing
2 changed files
with
26 additions
and
1 deletions
Show diff stats
test/unit/uploaded_file_test.rb
@@ -102,4 +102,29 @@ class UploadedFileTest < Test::Unit::TestCase | @@ -102,4 +102,29 @@ class UploadedFileTest < Test::Unit::TestCase | ||
102 | file.destroy | 102 | file.destroy |
103 | end | 103 | end |
104 | 104 | ||
105 | + should 'resize images bigger than in resize_to' do | ||
106 | + fixture_filename = '/files/test-large-pic.jpg' | ||
107 | + filename = RAILS_ROOT + '/test/fixtures' + fixture_filename | ||
108 | + system('echo "image for test" | convert -background yellow -page 1280x960 text:- %s' % filename) | ||
109 | + | ||
110 | + f = UploadedFile.create(:profile => @profile, :uploaded_data => fixture_file_upload(fixture_filename, 'image/jpg')) | ||
111 | + | ||
112 | + assert_equal [640, 480], [f.width, f.height] | ||
113 | + | ||
114 | + File.rm_f(filename) | ||
115 | + end | ||
116 | + | ||
117 | + should 'resize images on folder bigger than in resize_to' do | ||
118 | + fixture_filename = '/files/test-large-pic.jpg' | ||
119 | + filename = RAILS_ROOT + '/test/fixtures' + fixture_filename | ||
120 | + system('echo "image for test" | convert -background yellow -page 1280x960 text:- %s' % filename) | ||
121 | + f = Folder.create!(:name => 'test_folder', :profile => @profile) | ||
122 | + | ||
123 | + file = UploadedFile.create(:profile => @profile, :uploaded_data => fixture_file_upload(fixture_filename, 'image/jpg'), :parent_id => f.id) | ||
124 | + | ||
125 | + assert_equal [640, 480], [file.width, file.height] | ||
126 | + | ||
127 | + File.rm_f(filename) | ||
128 | + end | ||
129 | + | ||
105 | end | 130 | end |
vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb
@@ -419,7 +419,7 @@ module Technoweenie # :nodoc: | @@ -419,7 +419,7 @@ module Technoweenie # :nodoc: | ||
419 | 419 | ||
420 | # Resizes the given processed img object with either the attachment resize options or the thumbnail resize options. | 420 | # Resizes the given processed img object with either the attachment resize options or the thumbnail resize options. |
421 | def resize_image_or_thumbnail!(img) | 421 | def resize_image_or_thumbnail!(img) |
422 | - if (!respond_to?(:parent_id) || parent_id.nil?) && attachment_options[:resize_to] # parent image | 422 | + if !is_thumbnail? && attachment_options[:resize_to] # parent image |
423 | resize_image(img, attachment_options[:resize_to]) | 423 | resize_image(img, attachment_options[:resize_to]) |
424 | elsif thumbnail_resize_options # thumbnail | 424 | elsif thumbnail_resize_options # thumbnail |
425 | resize_image(img, thumbnail_resize_options) | 425 | resize_image(img, thumbnail_resize_options) |