Reputation: 5249
Is there a configuration setting in Paperclip to scale the orginal image down to a certain size instead of creating another version of the file?
If the user uploads a 750X750 image, I want to scale it down to 500x500. I will never use the 750x750 version so there is no reason to keep it around.
class User < ActiveRecord::Base
has_attached_file :avatar, :styles => { :thumb => "500x500>" }
end
Upvotes: 4
Views: 1124
Reputation: 2736
It might not be the prettiest solution but this could work. I'm curious to know if there is a better solution.
class User < ActiveRecord::Base
has_attached_file :avatar, :styles => { :original => "500x500>" }
after_create :delete_original_image
def delete_original_image
File.delete(self.avatar.path)
end
end
Upvotes: 0
Reputation: 9529
There is an easy way to override this. All you have to do is set your style to original:
class User < ActiveRecord::Base
has_attached_file :avatar, :styles => { :original => "500x500>" }
end
It won't save the original and take whatever the input image is and modify it to your specifications. Then when you want to access it, you won't need to specify a style.
image_tag @user.avatar
Instead of:
image_tag @user.avatar(:thumbnail)
Upvotes: 7