简体   繁体   中英

Images URL with Grails Resources plugin

I'm trying to use the elRTE widget in my Grails 2.0.3 app.

I've put the images in the web-app/images

The problem is some of the images display, and some don't, and I have no idea why

So for example:

<r:img uri="/images/smileys/evilgrin.png"/>
<r:img uri="/images/smileys/unhappy.png"/>
<img src="/block/static/images/smileys/evilgrin.png" />
<img src="/block/static/images/smileys/unhappy.png" />

evilgrin.png shows up just fine with either the <r:img /> tag or the <img /> tag, but unhappy.png, which is in the same directory does not.

For that matter, evilgrin.png wasn't showing up but while trying to figure out why, it suddenly appeared. Again, I have no idea why.

The elRTE toolbar shows up fine, but the drop-down menu with the smileys to insert doesn't, except for evilgrin.

Can anyone shed any light?

I'm using Grails 2.0.3 from within SpringSource Tool Suite 2.9.1 (eclipse) on Windows 7.

This behavior is likely due to some of the confusion surrounding the current use of ad-hoc, legacy, and undeclared resources in the Resources plugin. The 1.2 release (out soon) will contain further documentation of these behaviors.

The safest bet is to declare the images folder in the ad-hoc filter settings like:

grails.resources.adhoc.patterns = ["/images/*", "*.css", "*.js"]

(which is the default setting).

Then access the images using the <r:img> tag. Do not use the <img> tag with a src such as that given above.

You can test which actual URIs are being served from the application by using a curl command. The first attempt to access a URI like /images/smiles/evilgrin.png should produce a redirect to /static/images/smilies/evilgrin.png. The image should be served from this latter URI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM