Coder Social home page Coder Social logo

grails-image-indirect-plugin's Introduction

grails-image-indirect-plugin

Summary

A Grails plugin to serve images on your program located anywhere on your filesystem, not only on the application context path


More (short) info:

This grails plugin adds a new tag <ii:imageTag /> which allows your application to serve images located anywhere on your filesystem (outside your application context). I know. You could do it with some Apache (or other webServer) tricks, but sometimes this approach can be very convenient.

Use by example

Simplest use:

  • Add this variable on your Config.groovy

    imageindirect.basePath='/tmp/images'

    <li>Deploy a photo (say, myPhoto.jpg) on that folder
    <li>Write anywhere on your GSP: &lt;ii:imageTag indirect-imagename="myPhoto.jpg"/&gt; 
    <li>You got it!
    

A bit more advanced use:

You can define categories of photos and make them accessible both on relative or absolute paths. Example:

  • Add to your Config.groovy

    imageindirect.basePath='/tmp/images'

    imageindirect.category.landscapes='/tmp/landscapePhotos'

    imageindirect.category.macro='macroPhotos/'

  • Put on /tmp/images any photo. Say: "myAvatar.gif"

    Put on /tmp/landscapePhotos , "majorca.png"

    Put on /tmp/images/macroPhotos , for example, "antFace.jpg"

  • Write on your GSP:

    <ii:imageTag indirect-imagename="myAvatar.gif"/>

    <ii:imageTag indirect-category="landscapes" indirect-imagename="majorca.png"/>

    <ii:imageTag indirect-category="macroPhotos" indirect-imagename="antFace.jpg"/>

  • That's it!.

From v 0.0.4 you can use the plugin to store the images uploaded on the correct disk location. Just call the storeImage method on ImageIndirectService:

File storeImage(MultipartFile multipartFile, String desiredName = null, String category = null)

From v 0.0.5 you can also define a 'last resort' default file just in case the requested one doesn't exist. This can be very useful when you need things like a default icon, default user avatar image or something like that

grails-image-indirect-plugin's People

Contributors

burtbeckwith avatar jmiguelr avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.