class ActiveAdminAddons::ImageBuilder
Public Instance Methods
render()
click to toggle source
# File lib/activeadmin_addons/addons/image_builder.rb, line 3 def render return nil if data.nil? if Object.const_defined?('Paperclip::Attachment') && data.is_a?(Paperclip::Attachment) paperclip_data elsif Object.const_defined?('Shrine::UploadedFile') && data.is_a?(Shrine::UploadedFile) shrine_data else raise "you need to pass a paperclip or shrine image attribute" end end
Private Instance Methods
derivatives()
click to toggle source
# File lib/activeadmin_addons/addons/image_builder.rb, line 31 def derivatives model.send("#{attribute}_derivatives") end
paperclip_data()
click to toggle source
# File lib/activeadmin_addons/addons/image_builder.rb, line 17 def paperclip_data style = options.fetch(:style, :original) context.image_tag(data.url(style)) if data.file? end
shrine_data()
click to toggle source
# File lib/activeadmin_addons/addons/image_builder.rb, line 22 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