Plugins You can find out about all the publicly available Grails plugins.

ImageProxy Plugin

  • Tags: /
  • Latest: 0.2
  • Last Updated: 08 May 2009
  • Grails version: 1.1 > *
  • Authors: null
0 vote
compile "org.grails.plugins:image-proxy:0.2"





To integrate the plugin into your application just run the 'install-plugin' Grails script, e.g.

grails install-plugin image-proxy


The Image Proxy plugin allows you to serve images that are hosted on a server that is accessible by the webserver, but not by others.

Version 0.2 introduced a new mandatory tag. Please have a close look at the Usage section and don't forget to update your code!


  • Serve non-accessible images to your user
  • Local caching (currently real basic)
  • Completely hides the original source for the user
  • Supports all standard w3c attributes for the original IMG tag
  • Run-time customizable locations


Add the following example tag to your GSP:

<g:setLocation intloc="/var/www/images">
   <g:getImage src=""
      name="different-name" type="jpg" alt="Example image" width="84"
      onclick="alert('You clicked me!')" />

the above results in a normal <img> tag.

Optional: Add the following keys to your Config.groovy:

grails.serverURL = "http://localhost:8080/imageproxytest/"
proxy.location = "/var/www/images/imgProxy"
proxy.weblocation = "images/imgProxy"
  • grails.serverURL: Full url to your webapplication, use "http://localhost:8080/<your-project>/" for development
  • proxy.location: Relative or absolute path to a storage folder for the images on your hard drive
  • proxy.weblocation: Relative path from your grails.serverURL where the proxy.location path can be found

Attributes of setLocation

These attributes are optional. If they are not set, the locations will be grabbed from the configuration. If that isn't set, then default values will be used.

  • intloc: The internal location (or proxy.location)
  • webloc: The external location (or proxy.weblocation)
  • serverurl: The URL at which the app can be reached (or grails.serverURL)
Please remember to either set the locations in configuration OR specify the locations everytime the image is requested.

Attributes of getImage

Required attributes:

  • src: URL to the source image
  • name: Name of the image you want it to have when serving it to your users
  • type: Image type (jpg, gif, bmp, etc)
The Image Proxy plugin supports all the standard w3c img tag attributes:
  • id
  • class
  • title
  • style
  • lang
  • alt
  • src
  • height
  • width
  • ismap
  • longdesc
  • usemap
And the javascript event attributes:
  • onclick
  • ondblclick
  • onmousedown
  • onmouseup
  • onmouseover
  • onmousemove
  • onmouseout
  • onkeypress
  • onkeydown
  • onkeyup


Pascal de Vink - pascal dot de dot vink at gmail dot com

Please report any issues to the Grails User mailing list and/or write up an issue in JIRA at under the Grails-ImageProxy component.


  • February 22, 2009
    • released version 0.1
  • May 8, 2009
    • released version 0.2