Skip to content

Instantly share code, notes, and snippets.

@0xGGGGG
Created January 9, 2013 19:13
Show Gist options
  • Save 0xGGGGG/4495956 to your computer and use it in GitHub Desktop.
Save 0xGGGGG/4495956 to your computer and use it in GitHub Desktop.
retina carrierwave uploader snippet
{
:thumb => [142, 106],
:box_iphone => [296, 222],
:box_normal => [219, 164],
:box_large => [450, 340],
:normal => [600, 450]
}.each do |name, dimensions|
retina_name = "#{name}_retina"
version retina_name do
process resize_to_fill: [ dimensions[0] * 2, dimensions[1] * 2 ]
def full_filename(for_file = model.file.file)
parent_name = super(for_file)
ext = File.extname(parent_name)
base_name = parent_name.chomp(ext)
[base_name, "@2x"].compact.join('') + ext
end
end
version name do
process resize_to_fill: dimensions
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment