Last active
December 20, 2015 04:48
-
-
Save jcoyne/6073383 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Do you prefer option 'A' | |
makes_derivatives_of :content, when: :mime_type, is: 'application/pdf', | |
derivatives: { :thumb => "100x100>" } | |
makes_derivatives_of :content, when: :mime_type, is: 'audio/wav', | |
derivatives: { :mp3 => {format: 'mp3'}, :ogg => {format: 'ogg'} }, processors: :audio | |
makes_derivatives_of :content, when: :mime_type, is: 'video/avi', | |
derivatives: { :mp4 => {format: 'mp4'}, :webm => {format: 'webm'} }, processors: :video | |
makes_derivatives_of :content, when: :mime_type, is_one_of: ['image/png', 'image/jpg'], | |
derivatives: { :medium => "300x300>", :thumb => "100x100>" } | |
# or option 'B' | |
makes_derivatives_of :content do |obj, ds| | |
case obj.mime_type | |
when 'application/pdf' | |
obj.transform_datastream ds, { :thumb => "100x100>" } | |
when 'audio/wav' | |
obj.transform_datastream ds, { :mp3 => {format: 'mp3'}, :ogg => {format: 'ogg'} }, processor: :audio | |
when 'video/avi' | |
obj.transform_datastream ds, { :mp4 => {format: 'mp4'}, :webm => {format: 'webm'} }, processor: :video | |
when 'image/png', 'image/jpg' | |
obj.transform_datastream ds, { :medium => "300x300>", :thumb => "100x100>" } | |
end | |
end | |
# or option 'C' | |
makes_derivatives do |obj| | |
case obj.mime_type | |
when 'application/pdf' | |
obj.transform_datastream :content, { :thumb => "100x100>" } | |
when 'audio/wav' | |
obj.transform_datastream :content, { :mp3 => {format: 'mp3'}, :ogg => {format: 'ogg'} }, processor: :audio | |
when 'video/avi' | |
obj.transform_datastream :content, { :mp4 => {format: 'mp4'}, :webm => {format: 'webm'} }, processor: :video | |
when 'image/png', 'image/jpg' | |
obj.transform_datastream :content, { :medium => "300x300>", :thumb => "100x100>" } | |
end | |
end |
Oops, I forgot to say: FRIST!1!!!!!
Clarification: for context, see
C would be my pick.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C would be my first choice, with B close behind. I don't like A at all.