I'm trying to add a 2nd attachment to a model with Paperclip. I'm using a simple thumbnail processor like:
has_attached_file :attachment, :styles => { :thumb => "100x100>" }
has_attached_file :attachment2, :styles => { :thumb => "100x100>" }
I want it not to create thumbnails for non-image types like:
before_post_process :is_image?
def is_image?
!(File.extname(attachment_file_name) =~ /\A.jpe?g|pjpeg|gif|x-png|png\Z/i).nil?
end
How do I do that for the 2nd attachment? The problem being the reference to attachment_file_name which would need to be attachment2_file_name for the 2nd one.
It seems it's possible to write:
before_attachment_post_process :is_image?
before_attachment2_post_process :is_image2?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With