Request: Support style-specific processing images
Opened this issue · 2 comments
It would be great to handle processing_image_url
in the same way that Paperclip allows you to use an interpolator for :default_url
. The key feature is that this allows you to supply an image based on the syle which doesn't appear to be possible with processing_image_url
which isn't supplied with any context.
Usecase: Throughout my application I use square thumbs, whereas the rest of the images are their native aspect ratios. With Delayed Paperclip's current implementation there is no way to supply a square image to the thumnails and a generic 4:3 image to the rest of places it is used.
This might not be exactly what you are looking for, but I wanted to show style: :original
whereever I requested the original
file, even if it was still processing (and show all missing ones everywhere else, until processed).
I made this monkey patch:
(in initializers/delayed_paperclip.rb
)
module DelayedPaperclip
module UrlGenerator
alias_method :old_delayed_default_url?, :delayed_default_url?
def delayed_default_url?(style = nil)
return false if style == :original
old_delayed_default_url?(style)
end
end
end
You can pass processing_image_url
a string with values to be interpolated just like you would give Paperclip.
For example, I use a processing_image_url
like so:
process_in_background :image, processing_image_url: '/images/processing/:attachment/:style.gif'
This means if I call model.image.url(:square)
, I'd get back a URL like /images/processing/images/square.gif
.
If you need to pass processign_image_url
a callable, then you are right that you have no context to know which style to return.