Sha256: 065a448be587de489884728834b5e3ef75d69df7b16efd363872fd543058c3a5
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Alchemy # The persisted version of a rendered picture variant # class PictureThumb < ActiveRecord::Base belongs_to :picture, class_name: "Alchemy::Picture" validates :signature, presence: true validates :uid, presence: true class << self # Upfront generation of picture thumbnails # # Called after a Alchemy::Picture has been created (after an image has been uploaded) # # Generates three types of thumbnails that are used by Alchemys picture archive and # persists them in the configures file store (Default Dragonfly::FileDataStore). # # @see Picture::THUMBNAIL_SIZES def generate_thumbs!(picture) Alchemy::Picture::THUMBNAIL_SIZES.values.map do |size| variant = Alchemy::PictureVariant.new(picture, { size: size, flatten: true, }) signature = Alchemy::PictureThumb::Signature.call(variant) thumb = find_by(signature: signature) next if thumb uid = Alchemy::PictureThumb::Uid.call(signature, variant) Alchemy::PictureThumb::Create.call(variant, signature, uid) uid end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alchemy-dragonfly-s3-3.6.6 | app/models/alchemy/picture_thumb.rb |
alchemy-dragonfly-s3-3.6.5 | app/models/alchemy/picture_thumb.rb |