Hamza

Khan-Cheema


attachment_fu Thumbnail Size

As I mentioned earlier, when working with attachment_fu and image science the width and height of thumbnails were not being set correctly. So here is a method that I use to make sure that the data is set.



def set_image_dimensions
  if @image.width.blank? || @image.height.blank?
    ImageScience.with_image("#{RAILS_ROOT}/public/" << @image.public_filename) do |img|
      @image.height = img.height
      @image.width = img.width
    end
    @image.update_attribute('height',@image.height)
    @image.update_attribute('width',@image.width)
  end
end

Is anyone doing it differently ? Has this been addressed ?

Comments welcome.

Hamza

Comments

blog comments powered by Disqus