method
image_tag
v1.0.0 -
Show latest stable
- Class:
ActionView::Helpers::AssetTagHelper
image_tag(source, options = {})public
Returns an image tag converting the options into html options on the tag, but with these special cases:
- :alt - If no alt text is given, the file name part of the src is used (capitalized and without the extension)
- :size - Supplied as "XxY", so "30x45" becomes width="30" and height="45"
The src can be supplied as a…
- full path, like "/my_images/image.gif"
- file name, like "rss.gif", that gets expanded to "/images/rss.gif"
- file name without extension, like "logo", that gets expanded to "/images/logo.png"
3Notes
watch out for urls with &
image_tag('x.com/aaa?a=1&b=2') = x.com/aaa?a=1&b=2
By images's sub dirctionary to img tag
===
image_tag("icons/edit.png") # =>
![]()
Specify your own template
You can specify you own template this way:
def notice
...
@template = "some_other_name.html.erb"
end