Created
May 24, 2016 17:28
-
-
Save angelsystem/2bbf75218e8cc14e3fe9bd5758bca6cb to your computer and use it in GitHub Desktop.
This file contains 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
module Thumbnailable | |
extend ActiveSupport::Concern | |
def thumbnail_original | |
raise NotImplementedError | |
end | |
def thumbnail_path | |
return unless thumbnail? | |
image = MiniMagick::Image.read(thumbnail_original.read) | |
image.format('png') | |
image.resize(thumbnail_geometry) | |
image.path | |
end | |
def thumbnail_geometry | |
'440x440' | |
end | |
def thumbnail? | |
thumbnail_original && (thumbnail_original.image? || thumbnail_original.pdf?) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment