Skip to content

Instantly share code, notes, and snippets.

@antulik
Created August 13, 2015 05:49
Show Gist options
  • Save antulik/16cc6564bd4d55d1ac07 to your computer and use it in GitHub Desktop.
Save antulik/16cc6564bd4d55d1ac07 to your computer and use it in GitHub Desktop.
dragon fly helper
def thumb_url photo, size
case photo
when ImageUploader
if Rails.env.development?
path = photo.path
else
path = photo.url
end
when String
path = photo
else
raise "Unknown photo type #{photo.class}"
end
if path.starts_with? 'http'
Dragonfly.app.fetch_url(path).thumb(size).url
else
Dragonfly.app.fetch_file(path).thumb(size).url
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment