Help with Ignoring styles in paperclip processors ?!?

6 views
Skip to first unread message

hiddenloop

unread,
Mar 24, 2009, 1:39:12 PM3/24/09
to Paperclip Plugin
Hi,

I have written a small processor, that basically looks at the filetype
and if it is deemed to be 'editable' (ie. plain txt or html) - it save
the contents of the upload file into a text attribute on the rails
model (asset_contents)

The problem I have is that I have multiple styles on the attachment
like so;;

<pre>
has_attached_file :asset, :styles => { :thumb =>
["64x64#", :jpg], :preview => ["200x", :jpg] },
:path => ":rails_root/public/images/u/
assets/:class/:id/:style_:basename.:extension",
:url => "/images/u/
assets/:class/:id/:style_:basename.:extension",
:default_url => "/images/missing_:class.gif",
:processors => lambda { |u| u.editable? ?
[ :file_content_processor ] : [ :thumbnail ] }
</pre>

In this case, my file_content_processor is fired for each of the
styles, effectively doing the operation twice (when I only want it
done once)
This also give me three files, the original (txt file), and a thumb
and preview (both jpg's with plain text content)

In the paperclip docs its states;

"" then both the :rotator processor and the :ocr processor would
receive the options "{ :quality => :better }". This parameter may not
mean anything to one or more or the processors, and they are free to
ignore it. ""

My question is, how do I ignore the multiple styles and have my
file_content_processor, just fire once ?

Ps.. my file content processor code is here;

http://pastie.org/425598

Regards,

Matt
Reply all
Reply to author
Forward
0 new messages