Module: Elabs::ThumbnailsHelper
- Defined in:
- app/helpers/elabs/thumbnails_helper.rb
Constant Summary collapse
- THUMBNAILS_DIMENSIONS =
{ small: '50x50', medium: '300x300' }.freeze
- AVATAR_DIMENSIONS =
{ large: '512', medium: '256', small: '64' }.freeze
Instance Method Summary collapse
- #avatar_image(avatar, size = :medium) ⇒ Object
- #image_resize_properties(size = :page) ⇒ Object
- #resize_and_center_crop(entity, size) ⇒ Object
- #thumbnail_center_crop(document, size = :medium) ⇒ Object
- #thumbnail_preview_placeholder_file ⇒ Object
Instance Method Details
#avatar_image(avatar, size = :medium) ⇒ Object
35 36 37 |
# File 'app/helpers/elabs/thumbnails_helper.rb', line 35 def avatar_image(avatar, size = :medium) resize_and_center_crop avatar, AVATAR_DIMENSIONS[size] end |
#image_resize_properties(size = :page) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/elabs/thumbnails_helper.rb', line 24 def image_resize_properties(size = :page) dimensions = case size when :large '1920x1080' else '960x540' # page size end { resize: dimensions } end |
#resize_and_center_crop(entity, size) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'app/helpers/elabs/thumbnails_helper.rb', line 39 def resize_and_center_crop(entity, size) x = entity.blob.[:width].to_f y = entity.blob.[:height].to_f bigger_size = x < y ? x : y = { combine_options: { gravity: 'center', crop: "#{bigger_size}x#{bigger_size}+0+0", resize: size.to_s } } main_app.url_for(entity.representation().processed) end |
#thumbnail_center_crop(document, size = :medium) ⇒ Object
14 15 16 17 18 |
# File 'app/helpers/elabs/thumbnails_helper.rb', line 14 def thumbnail_center_crop(document, size = :medium) return resize_and_center_crop(document, AVATAR_DIMENSIONS[size]) if document.representable? thumbnail_preview_placeholder_file end |
#thumbnail_preview_placeholder_file ⇒ Object
20 21 22 |
# File 'app/helpers/elabs/thumbnails_helper.rb', line 20 def thumbnail_preview_placeholder_file '/assets/elabs/preview_placeholder.png' end |