Grails will not display images in subfolder using tag
I have image files in a Grails project, for example:
grails-app/assets/images/admin/img1.jpg
I am trying to display it like:
<g:img dir="images/admin" file="img1.jpg">
It does not appear in the development environment (Grails 2.4). I am getting 404. However, if I copy the image to:
grails-app/assets/images/img1.jpg
and change the code like below:
<g:img dir="images" file="img1.jpg">
it works.
Plugin I am using:
build ":tomcat:7.0.55"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.8'
compile ":asset-pipeline:1.9.9"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
+3
source to share
1 answer
From what I can see, Abs was a very close test.
<asset:image src="admin/img1.jpg" />
If you link to:
http://bertramdev.github.io/asset-pipeline/guide/usage.html
in section 4.3:
Assets can also be listed in subdirectories if needed and simply require using a relative path.
<asset:image src="icons/delete.png"/>
so they are already in images and have a folder with icons
You can also do something like this with an alternative method:
<img src="${assetPath(src: 'admin/img1.jpg')}"/>
<g:img src="${assetPath(src: 'admin/img1.jpg')}"/>
+2
source to share