← Back to all posts

Paperclip run processors for specific style

David Anderson | May 06, 2019

If you have a Paperclip custom processor that you want to run on specific styles, you can change the has_attached_file styles hash so that each style includes a processors array. For example, in the code below only the full and thumb styles will be sent to the cropper processor.

  has_attached_file :photo,
    styles: {
      auto_orient: {}, 
      full:  {geometry: '512x512>', processors: [:cropper]}, 
      thumb: {geometry: '256x256>', processors: [:cropper]}
    },
    default_url: "/:class/:attachment/default.png"
SUBSCRIBE

Drop your email in the box below to subscribe to my newsletter. Once per week you'll get Ruby/Rails tips, guides, job postings, and general thoughts from the web developer trenches.