Sha256: 9560ed5194996842f0d5a35c7f8d50989b2c7b5e093a21171ee3c4343d03fe98
Contents?: true
Size: 683 Bytes
Versions: 27
Compression:
Stored size: 683 Bytes
Contents
module Spina class Image < ApplicationRecord belongs_to :media_folder, optional: true has_one_attached :file scope :sorted, -> { order('created_at DESC') } def name file.try(:filename).to_s end def variant(options) return "" unless file.attached? return file if file.content_type.include?('svg') return file unless file.variable? file.variant(options) end def content self end def thumbnail(size = '100x100', modifier = '^') variant( combine_options: { gravity: 'center', thumbnail: "#{size}#{modifier}", extent: size } ) end end end
Version data entries
27 entries across 27 versions & 1 rubygems