• rails image_tag生成图片标签


    image_tag(source, options={})

    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" />
    
  • 相关阅读:
    客户端验证用户名和密码
    特殊日期提示
    python 多态这一部分的知识点相关应用
    类的继承
    栈,队列的应用
    生成器与for循环的纠葛
    类(class)的形成过程
    报错信息看着哇
    死脑筋要活用(我只放贴图)01
    正则运算跟py语言的结合,知识点层出不穷
  • 原文地址:https://www.cnblogs.com/wangyuyu/p/3235612.html
Copyright © 2020-2023  润新知