Catalyst::Plugin::Images.3pm

Langue: en

Version: 2007-09-15 (mandriva - 01/05/08)

Section: 3 (Bibliothèques de fonctions)

NAME

Catalyst::Plugin::Images - Generate image tags for static files.

SYNOPSIS

         use Catalyst qw/
         Images
     /;
 
 
     # ... somewhere in your templates
 
 
     [% c.image_tag("foo.png" => "alt text") %];
 
 

DESCRIPTION

This plugin aims to assist you in generating image tags that contain alt text, a properly escaped src attribute, height and width info, without worrying too much.

METHODS

image_tag $basename, %attrs
This method generates an image tag for the image named $basename, with the extra tags %attr.
get_image_info $basename
Retrieve the information about the image either from the cache or by searching for it.
find_image_file $basename
Look inside all the search paths (see ``CONFIGURATION'') for an image named $basename, and return the full path to it, as a <Path::Class::File> object..
read_image_info $path
Given the full path, as a Path::Class::File object, return the attributes to be added to the image. This returns a list with "width" and "height", using "Image::Size".
image_path_to_uri $path, $basename
Generates a URI using ``uri_for'' in Catalyst, with the absolute path $path relativized to "uri_base". See </CONFIGURATION>.
get_cached_image_info
set_cached_image_info
see ``CACHING IMAGE DATA'' below.
setup
Overridden to seed configuration defaults.

CONFIGURATION

All configuration information is stored under the "images" key.
paths
This should be an array reference of Path::Class::Dir objects (easily generated with ``path_to'' in Catalyst) in which to search for images.

It defaults to "root/static", "root/images", "root/static/images" by default.

uri_base
This is the ``base'' prefix path for URI generation. For example, if an image was found at "/www/static/images/foo.png" and "uri_base" is "/www" then the URI generated with "Catalyst/uri_for" will be for "/static/images/foo.png".

CACHING IMAGE DATA

The code will call "get_cached_image_info" and "set_cached_image_info" when appropriate. Currently both these operations are no op. You should override this if you care.

"get_cached_image_info" receives the base name, and should return the info hash.

"set_cached_image_info" receives the base name, and the info hash. It can use this data to expire the cache based on mtime, etc. The info hash contains the keys "width", "height", "uri", and "path".

SEE ALSO

Catalyst, Catalyst::Plugin::Static::Simple, Image::Size