Grails Resources plugin, modules and to render images? -



Grails Resources plugin, modules and <r:img> to render images? -

trying larn resources plugin

from understanding, helps define 'resources' such css , javascript files , automatically pull them gsp's when needed. understand how create modules can loaded in using tags etc.

the part im not understanding this: http://grails-plugins.github.com/grails-resources/guide/4.%20using%20resources.html#4.2%20linking%20to%20images

so ive created module called 'images' in config.groovy follows:

grails.resources.modules = { images { resource url:'/images/view.jpg', attrs:[width: 1280, height:720 , alt: 'my view'] resource url:'/images/breakfast.jpg', attrs:[width: 1280, height:720, alt: 'breakfast'] } }

the resources included in .gsp page in head section follows:

<head> <r:require modules="jquery-ui, blueprint"/> </head>

i know resources have been added head section because when inspect page source see them there:

<link href="/resourcetest/static/aa7jv0n2qzjoz7tlz9cl5creih2y5jjyv0ytn4nqg9r.jpg" rel="shortcut icon" width="1280" height="720" alt="my view" /> <link href="/resourcetest/static/ipqbsjryelddsubgbp3jhf6kkhvu1zv3xrtwwfkoimn.jpg" rel="shortcut icon" width="1280" height="720" alt="breakfast" />

my question this: how image resources used? mean know if javascript, importing of resource gives access utilize functions in html code, regards images, site says "once have done this, using reference them automatically set width, height , other attributes."

how? i've tried following:

<r:img module="images"> <r:img alt="breakfast">

and handful of others no success

what work is:

<r:img uri="/images/breakfast.jpg">

but works regardless of whether or not add together module r:require tag.. whats point of using plugin images , how utilize it?

the <r:img> tag works fine our without <r:require>; it works undeclared image resources.

the point of require tag prevent resource duplication. so, instance, suppose have multiple javascript resources rely on jquery, , they're required. add together layer of complication: you're pulling different gsp templates via sitemesh, , each have own resource dependencies. if set normal html code reference resources in head of each gsp layout, might multiple instances of them in page header, prove problematic. using resources plugin makes sure 1 instance of required resource.

see http://grails-plugins.github.io/grails-resources/ref/tags/require.html , http://grails-plugins.github.io/grails-resources/ref/tags/layoutresources.html.

with images, though, not necessary. if have image more 1 time on page, it's because wanted it, or because you're applying redundant layouts , need refactor bit. so, right require tag doesn't much images called via <r:img>. because images different sort of resource, they're treated differently. don't sweat it. :)

image grails plugins module

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -