Created
August 13, 2015 05:49
-
-
Save antulik/16cc6564bd4d55d1ac07 to your computer and use it in GitHub Desktop.
dragon fly helper
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
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