Sha256: 5db9e68326a47207941fad510bfe031926bce0cee2338c87b4fc9e50e7c92c6e
Contents?: true
Size: 774 Bytes
Versions: 4
Compression:
Stored size: 774 Bytes
Contents
module ActiveAdminAddons class ImageBuilder < CustomBuilder def render return nil if data.nil? if Object.const_defined?('Shrine::UploadedFile') && data.is_a?(Shrine::UploadedFile) shrine_data else raise "you need to pass a shrine image attribute" end end private def shrine_data image_options = options[:image_options].presence || {} if options[:style] && derivatives.include?(options[:style]) context.image_tag(model.send("#{attribute}_url", options[:style]), image_options) else context.image_tag(data.url, image_options) end end def derivatives model.send("#{attribute}_derivatives") end end end ActiveAdminAddons::ImageBuilder.create_view_methods
Version data entries
4 entries across 4 versions & 1 rubygems