NAME
Rose::HTML::Image - Object representation of the "img" HTML tag.
SYNOPSIS
$img = Rose::HTML::Image->new(src => '/logo.png',
alt => 'Logo');
$i->document_root('/var/web/htdocs');
# <img alt="Logo" height="48" src="/logo.png" width="72">
print $i->html;
$i->alt(undef);
# <img alt="" height="48" src="/logo.png" width="72" />
print $i->xhtml;
...
DESCRIPTION
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.
HTML ATTRIBUTES
Valid attributes:
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
Required attributes:
alt
src
Boolean attributes:
ismap
CONSTRUCTOR
- new PARAMS
-
Constructs a new
Rose::HTML::Image
object based on PARAMS, where PARAMS are name/value pairs. Any object method is a valid parameter name.
OBJECT METHODS
- document_root [PATH]
-
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 environment, the document root defaults to the value returned by:
Apache->request->document_root
This call is made once for each
Rose::HTML::Image
object that needs to use the document root. - init_size [PATH]
-
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 thepath()
attribute is set, that path is used. Failing that, the width and height HTML attributes are simply not modified. - path [PATH]
-
Get or set the path to the image file on disk.
If a PATH argument is passed and
document_root()
is defined, then PATH hasdocument_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 ofdocument_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. - src [SRC]
-
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 ofdocument_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.
AUTHOR
John C. Siracusa (siracusa@mindspring.com)