image_tag(source, options={}) Link

Returns an HTML image tag for thesource. The source can be a full path or a file.

Options

You can add HTML attributes using theoptions. The options supports three additionalkeys for convenience and conformance:

  • :alt - If no alt text is given, the file name part of thesource is used (capitalized and without the extension)

  • :size - Supplied as "{Width}x{Height}" or "{Number}", so"30x45" becomes width="30" and height="45", and "50" becomes width="50" andheight="50". :size will be ignored if the value is not in thecorrect format.

Examples

image_tag("icon")
# => <img alt="Icon" src="/assets/icon" />
image_tag("icon.png")
# => <img alt="Icon" src="/assets/icon.png" />
image_tag("icon.png", size: "16x10", alt: "Edit Entry")
# => <img src="/assets/icon.png" width="16" height="10" alt="Edit Entry" />
image_tag("/icons/icon.gif", size: "16")
# => <img src="/icons/icon.gif" width="16" height="16" alt="Icon" />
image_tag("/icons/icon.gif", height: '32', width: '32')
# => <img alt="Icon" height="32" src="/icons/icon.gif" width="32" />
image_tag("/icons/icon.gif", class: "menu_icon")
# => <img alt="Icon" class="menu_icon" src="/icons/icon.gif" />

最新文章

  1. Java程序设计的DOS命令基础
  2. 基于VirtualBox安装Ubuntu图文教程
  3. JSAPI_Ticket签名
  4. C#操作FTP, FTPHelper和SFTPHelper
  5. [转]Kerberos简介
  6. 关于join算法的四篇文章
  7. [转贴]C++开源库
  8. Another app is currently holding the yum lock; waiting for it to exit... 怎么解决
  9. 开源的.NET媒体文件操作组件TagLib#解析
  10. win7 重装 docker 启动后无法启动错误解决
  11. MyEclipse出现红色感叹号解决办法
  12. Python开发:Python2和Python3的共存和切换使用
  13. Java实现登录验证码
  14. P2921 [USACO08DEC]在农场万圣节Trick or Treat on the Farm 记忆化搜索dfs
  15. CSS3-2
  16. 记数据库数据文件损坏恢复ORA-00376+ORA-01110
  17. SQL Server 锁实验(SELECT加锁探究)
  18. 插入排序Java版
  19. PAT-Top1002. Business (35)
  20. [转]浅谈Android五大布局(一)——LinearLayout、FrameLayout和AbsoulteLayout

热门文章

  1. WP8.1 中获取背景色和主题色
  2. Elasticsearch 的一些关键概念
  3. 微软官方实例 RazorPagesMovie 在 asp.net core 2.1 版本下的实战
  4. DropDownList切换选择,服务器控件Repeater未更新
  5. ASP.NET Core SignalR CORS 跨域问题
  6. .Net Core in Docker - 在容器内编译发布并运行
  7. sql server 修改表字段信息
  8. musql 添加字段语句
  9. C#中泛型类,泛型方法,泛型约束实际应用
  10. Android---------------Service的学习