class Para::AttributeField::ImageField

Public Instance Methods

excerptable_value?() click to toggle source
# File lib/para/attribute_field/image.rb, line 16
def excerptable_value?
  false
end
value_for(instance) click to toggle source
# File lib/para/attribute_field/image.rb, line 8
def value_for(instance)
  style = attachment_thumb_style_for(instance)

  if instance.send(:"#{ name }?")
    image_tag(instance.send(name).url(style))
  end
end

Private Instance Methods

attachment_thumb_style_for(instance) click to toggle source
# File lib/para/attribute_field/image.rb, line 22
def attachment_thumb_style_for(instance)
  styles = instance.send(name).styles.map(&:first)
  # Check if there's a :thumb or :thumbnail style in attachment definition
  thumb = styles.find { |s| %w(thumb thumbnail).include?(s.to_s) }
  # Return the potentially smallest size !
  thumb || styles.first || :original
end