How to add a condition to certain clip styles?

I have a model called Graphic, each graphic belongs to one model called Book, the graphic model has 1 style, and I want to add a second one called "dealer_logo":

:thumb       => ['75x75>],
:dealer_logo => ['200x45>', :jpg], :if => Proc.new {|file| Book.find(self.book_id).origin_id == 33}

I want the dealer_logo style to be generated, but if Book.origin_id is 33, I cannot get this code to work.

Can anyone give me any directions?

thank

+3
source share
1 answer

You will need to use a custom processor: https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/processor.rb

Paperclip:: Processor, , , . Rails apps lib/paperclip_processors paperclip, . : processor: has_attached_file:

has_attached_file :scan, :styles => { :text => { :quality => :better } },
                       :processors => [:ocr]
0

Source: https://habr.com/ru/post/1775287/


All Articles