img
目的 Purpose
Renders an HTML <img>
tag for an image resource.This tag uses g:resource
to generate the link to the resource, so it is implicitly aware of the Resources plugin.使用例 Examples
Example usages for the "shop" app:<g:img dir="images" file="logo.png" width="40" height="40"/> Output: <img src="/shop/images/logo.png" width="40" height="40"/><g:img uri="/images/icons/add.png"/> Output: <img src="/shop/images/logo.png"/>
<r:img>
which will include any HTML attributes defined in the image's resource definition, if one exists.詳細 Description
属性 Attributes
base
(optional) - Sets the prefix to be added to the link target address, typically an absolute server URL. This overrides the behaviour of theabsolute
property if both are specified.contextPath
(optional) - the context path to use (relative to the application context path). Defaults to "" or path to the plugin for a plugin view or template.dir
(optional) - the name of the directory containing the resourcefile
(optional) - the name of the resource fileabsolute
(optional) - Iftrue
will prefix the link target address with the value of thegrails.serverURL
property fromConfig.groovy
, or http://localhost:<port> if there is no setting inConfig.groovy
and not running in production.plugin
(optional) - The plugin to look for the resource inuri
(optional) - If using the Resources plugin, the uri of the image. A more terse alternative to using the dir/file attributes.