Use original file as default_url?

Hi - I am working on updating to Shrine 3 from 2.x and one thing that I was hoping to be able to do was to use the original file_url in the cases where derivatives like file_url(:small) have not yet been created due to background processing. I realize that I could use a static image with the default_url plugin, but I am hoping to just fall back to the original. Can this be done?

In case anyone comes across this by search, I think I solved it myself.

  Attacher.default_url do |derivative: nil, **|
    record.file_url if derivative
  end

Good that you found a solution. Note that you wanted to keep it model-agnostic, you can also call Attacher#url directly:

Attacher.default_url do |derivative: nil, **|
  url if derivative
end
1 Like