Rose::HTML::Image - Object representation of the "img" HTML tag.
$img = Rose::HTML::Image->new(src => '/logo.png', alt => 'Logo'); $img->document_root('/var/web/htdocs'); # <img alt="Logo" height="48" src="/logo.png" width="72"> print $img->html; $img->alt(undef); # <img alt="" height="48" src="/logo.png" width="72" /> print $img->xhtml; ...
Rose::HTML::Image is an object representation of the <img> HTML tag. It includes the ability to automatically fill in the "width" and "height" HTML attributes with the correct values, provided it is given enough information to find the actual image file on disk. The Image::Size module is used to read the file and determine the correct dimensions.
This class inherits from, and follows the conventions of, Rose::HTML::Object. Inherited methods that are not overridden will not be documented a second time here. See the Rose::HTML::Object documentation for more information.
alt class dir height id ismap lang longdesc name onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup src style title usemap width xml:lang
Constructs a new Rose::HTML::Image object based on PARAMS, where PARAMS are name/value pairs. Any object method is a valid parameter name.
Get or set the web site document root. This is combined with the value of the "src" HTML attribute to build the path to the actual image file on disk.
If running in a mod_perl 1.x environment, the document root defaults to the value returned by:
If running in a mod_perl 2.x environment, the document root defaults to the value returned by:
Note that you must have the
GlobalRequest option set for this to work. If you do not, the document root defaults to undef.
These calls are made once for each Rose::HTML::Image object that needs to use the document root.
Try to set the "width" and "height" HTML attributes but using Image::Size to read the image file on disk. If a PATH argument is passed, the image file is read at that location. Otherwise, if the path() attribute is set, that path is used. Failing that, the width and height HTML attributes are simply not modified.
Get or set the path to the image file on disk.
If a PATH argument is passed and document_root() is defined, then PATH has document_root() removed from the front of it (substitution anchored at the start of PATH) and the resulting string is set as the value of the "src" HTML attribute. Regardless of the value of document_root(), init_size() is called in an attempt to set the "height" and "width" HTML attributes.
The current value of the
path object attribute is returned.
Get or set the value of the "src" HTML attribute.
If a SRC argument is passed and a file is found at the path specified by SRC, then path() is set to SRC. Otherwise, path() is set to the concatenation of document_root() and SRC. In either case, init_size() is called in an attempt to set the "height" and "width" HTML attributes.
The current value of the "src" HTML attribute is returned.
John C. Siracusa (firstname.lastname@example.org)
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.