Skip to content

Instantly share code, notes, and snippets.

@angelsystem
Created May 24, 2016 17:28
Show Gist options
  • Save angelsystem/2bbf75218e8cc14e3fe9bd5758bca6cb to your computer and use it in GitHub Desktop.
Save angelsystem/2bbf75218e8cc14e3fe9bd5758bca6cb to your computer and use it in GitHub Desktop.
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