I have the following definition in my model:
has_attached_file :file, :styles => { :medium => "300x200#", :large =>
"600x400#" }
Right now the user is allowed to upload JPEGs or PDFs. I would like to
apply the styles as defined if the upload is a JPEG and skip the
styles completely if the upload is a PDF.
Any way to do this? Thanks in advance.
-Poul
With the current master you can do something like this:
has_attached_file :file, :styles => lambda { |attachment|
if attachment.instance_read(:content_type) == 'image/jpeg'
{ :medium => "300x200#", :large => "600x400#" }
else
{}
end
}
If it gets any more complex than jpeg-or-not, you'll run into all sorts of annoying quirks in the variety and inconsistency of uploaded content types. I've ended up moving all that into an AssetType class which looks up styles and processors based on uploaded mime-type.
best,
will
Thanks,
matt
-Poul