Method: Padrino::Helpers::AssetTagHelpers#image_tag

Defined in:
padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb

#image_tag(url, options = {}) ⇒ String

Creates an image element with given url and options.

Examples:

image_tag('icons/avatar.png')

Parameters:

  • url (String)

    The source path for the image tag.

  • options (Hash) (defaults to: {})

    The html options for the image tag.

Returns:

  • (String)

    Image html tag with url and specified options.


210
211
212
213
214
# File 'padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb', line 210

def image_tag(url, options={})
  options = { :src => image_path(url) }.update(options)
  options[:alt] ||= image_alt(url) unless url.to_s =~ /\A(?:cid|data):|\A\Z/
  tag(:img, options)
end