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
Hamza Khan-Cheema is a freelance web developer based in London. He specialises in agile web development using Ruby on Rails. He has been involved in web applications for the past 5 years utilising multiple technologies and practices. More...
Comments