Join Newsletter


Share with:

Recent Posts

paperclip Tag

When using Paperclip to save an attached image, how do I get & store the dimensions of the image? Best way is to create two fields to store the width & height and then just populate those fields when the image loads. (Other solutions, like reading it dynamically each, incur a lot of unnecessary disk activity.) Be sure to checkout some basic tutorials on Paperclip if you are unfamiliar with it generally. (see references below 1 2 3)

Step by step instructions.

1. create a new file at lib/paperclip_processors/thumbnail_with_dimensions.rb

2. Paste the contents of this gist into the newly created file:

1) be sure to put in your environment file (inside your initializer) config.gem "paperclip" 2) make sure your form_form has multipart set to true like this: { :multipart => true } do |f| %> 3) if using passenger, you must put this in config/initializers/paperclip.rb: if RAILS_ENV == "development" ...

Read More