"Fossies" - the Fresh Open Source Software Archive

Member "grails-core-5.2.4/grails-docs/src/test/resources/docs/ref/Tags/img.html" (14 Sep 2022, 62030 Bytes) of package /linux/www/grails-core-5.2.4.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the grails-core-5.2.4.tar.gz project site itself.

(Quick Reference)



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.


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"/>

Note that if the Resources plugin is installed this will defer to <r:img> which will include any HTML attributes defined in the image’s resource definition, if one exists.



  • base (optional) - Sets the prefix to be added to the link target address, typically an absolute server URL. This overrides the behaviour of the absolute 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 resource

  • file (optional) - the name of the resource file

  • absolute (optional) - If true will prefix the link target address with the value of the grails.serverURL property from application.groovy, or http://localhost:<port>; if there is no setting in application.groovy and not running in production.

  • plugin (optional) - The plugin to look for the resource in

  • uri (optional) - If using the Resources plugin, the uri of the image. A more terse alternative to using the dir/file attributes.