How to use mime_type in derivatives block? #667
-
I'd like access to the derived mime_type (or all of the metadata) when creating derivatives, but the derivatives block only takes in "original" (a reference to the original file)
Is there any way to access that there? I tried using The specific problems I'm trying to handle are:
My full code right now looks like this:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can pass Attacher.derivatives(download: false) do |source|
next {} if %w[video/mpeg image/gif ...].include?(source.mime_type)
shrine_class.with_file(source) do |file|
magick = ImageProcessing::MiniMagick
.source(file)
.saver(quality: 60)
{
thumbnail: magick.coalesce.resize_to_limit!(128, 128),
optimized: magick.coalesce.resize_to_limit!(1024, 1024)
}
end
end |
Beta Was this translation helpful? Give feedback.
You can pass
download: false
to theAttacher.derivatives
call, and download the uploaded file yourself: