Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble resizing the default image with Paperclip

I want to be able to resize the default profile image I use with Paperclip. This is the code in my model:

has_attached_file :photo,
  :styles => {
    :tiny => "25x25#",
    :thumbnail => "100x100#",
    :small  => "150x150>",
    :medium => "300x300>" },
    :default_url => "/images/default.png"

However, the default image doesn't get resized like the user submitted images do. How can I do this?

like image 522
user730569 Avatar asked May 13 '11 05:05

user730569


1 Answers

The solution I've been using is to specify the style for the default image:

has_attached_file :photo,
:styles => {
  :tiny => "25x25#",
  :thumbnail => "100x100#",
  :small  => "150x150>",
  :medium => "300x300>" },
  :default_url => "/images/default_:style.png"

Then create a default image for each style (eg: default_tiny.png that is 25x25px, etc...)

Hope that helps.

like image 145
ericalli Avatar answered Sep 28 '22 05:09

ericalli