Sha256: 24d2b36e0f3423960fc3bebb5450b79cc2dab7441538fc53270f706868b6f88c
Contents?: true
Size: 1.3 KB
Versions: 59
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Alchemy class PictureThumb < BaseRecord # Stores the render result of a Alchemy::PictureVariant # in the configured Dragonfly datastore # (Default: Dragonfly::FileDataStore) # class Create class << self # @param [Alchemy::PictureVariant] variant the to be rendered image # @param [String] signature A unique hashed version of the rendering options # @param [String] uid The Unique Image Identifier the image is stored at # # @return [Alchemy::PictureThumb] The persisted thumbnail record # def call(variant, signature, uid) image = variant.image image.to_file(server_path(uid)).close variant.picture.thumbs.create!( picture: variant.picture, signature: signature, uid: uid, ) end private # Alchemys dragonfly datastore config seperates the storage path from the public server # path for security reasons. The Dragonfly FileDataStorage does not support that, # so we need to build the path on our own. def server_path(uid) dragonfly_app = ::Dragonfly.app(:alchemy_pictures) "#{dragonfly_app.datastore.server_root}/#{uid}" end end end end end
Version data entries
59 entries across 59 versions & 1 rubygems