[interchange-cvs] interchange - docelic modified code/SystemTag/image.tag

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Tue Oct 5 07:11:08 EDT 2004

User:      docelic
Date:      2004-10-05 11:11:08 GMT
Modified:  code/SystemTag image.tag
- header/license fix

- QUOTING fix: please inspect

Revision  Changes    Path
1.9       +7 -168    interchange/code/SystemTag/image.tag

rev 1.9, prev_rev 1.8
Index: image.tag
RCS file: /var/cvs/interchange/code/SystemTag/image.tag,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- image.tag	23 Jul 2004 03:42:52 -0000	1.8
+++ image.tag	5 Oct 2004 11:11:08 -0000	1.9
@@ -1,169 +1,9 @@
-UserTag image Version 0.03
+# Copyright 2002 Interchange Development Group (http://www.icdevgroup.org/)
+# Licensed under the GNU GPL v2. See file LICENSE for details.
+# $Id: image.tag,v 1.9 2004/10/05 11:11:08 docelic Exp $
 UserTag image Order src
 UserTag image AddAttr
-UserTag image Documentation <<EOD
-=head2 image
-This is a general-purpose tag for inserting HTML C<< <img> >> tags based on
-various settings, with the ability to test whether an image exists,
-predetermine its pixel dimensions, retrieve the image name from the
-product database field B<image> for that sku, automatically pull product
-descriptions from the database for use in the B<alt> and B<title>
-attributes, and access http/secure and storefront/admin UI image
-directory names.
-A convenient use is for displaying product images, for example on the
-	[image [item-code]]
-Given sku os29000 in the Foundation demo, and assuming the products
-database specifies os29000.gif in the B<image> field for os29000,
-the tag returns HTML code something like this:
-	<img src="/standard/images/os29000.gif" width=120 height=150
-	alt="3' Step Ladder" title="3' Step Ladder">
-If file os29000.gif hadn't existed, or the products database B<image>
-field were empty, the tag would check for files called "(sku).jpg",
-"(sku).gif", etc. and use the first one it found.
-You can also specify a particular image filename, but also give the
-sku to look up the description in the database:
-	[image sku="[item-code]" src="/standard/silly/putty.jpg"]
-You can force the use of an image filename even if the file doesn't
-exist (for example, if it is on a different server). Any absolute URL
-(http://... or https://...) is always accepted without checking, and
-the B<force> attribute overrides checking on any filename.
-One peculiar use is with the B<dir_only> parameter to return the correct
-prefix for images (normal or secure), primarily for adding to image names
-found in e.g. JavaScript code (rollovers, etc.) that we can't hope to
-have Interchange parse on its own as it does for plain HTML by default.
-Parameters for this tag are:
-=over 4
-=item alt
-Text to use for the C<< <img alt="..."> >> attribute. By default, this will
-be filled with the B<description> from the product database if a sku (not
-a filename) is provided.
-=item default
-Set this attribute to an image filename or relative or absolute URL
-to use if the file named in the B<src> attribute or the filename
-found in the product table B<image> field are not found.
-Defaults to scratch mv_defaultimage if set.
-=item descriptionfields
-A whitespace-separated list of fields in the product database from which
-to draw the description, used as the default in alt and title attributes.
-Catalog variable DESCRIPTIONFIELDS is a fallback if this option is not
-passed in.
-=item dir_only
-Set this attribute to 1 to return only the text of configuration
-variable ImageDir or ImageDirSecure, depending on whether the page is
-being delivered through the web server by http or https.
-=item exists_only
-Set this attribute to 1 if you want to check only whether an appropriate
-image file exists. The tag will return '1' if an image exists, and nothing
-if not.
-=item force
-Skip checking for existence of image file.
-=item getsize
-Use the Perl Image::Size module, if available, to determine the image's
-width and height in pixels, and pass them as arguments to the <img> tag.
-This is the default behavior; pass B<getsize=0> to disable.
-=item imagesubdir
-Look for any image filenames in the named subdirectory of the ImageDir,
-rather than directly in the ImageDir.
-For example, with the Foundation demo, the individual product images are
-in the subdirectory B<items/>, so you would set B<imagesubdir=items>. This
-is better than passing in B<src="items/os28009.gif"> because the tag
-knows the sku and can do products database lookups based on it.
-Defaults to scratch mv_imagesubdir if set.
-=item makesize
-If ImageMagick is installed, you can display an arbitrary size of
-the image, creating it if necessary.
-This will create a subdirectory corresponding to the size, (i.e. 64x48)
-and copy the source image to it. It will then use the ImageMagick C<mogrify>
-command to resize.
-This requires a writable image directory, of course.
-Looks for the c<mogrify> command in the path (with /usr/X11R6/bin added).
-If it will not be found there, or to improve performance slightly, you
-can set in interchange.cfg:
-	Variable IMAGE_MOGRIFY  /path/to/mogrify
-Sets umask to 2 temporarily when creating directories or files.
-=item secure
-This attribute forces using either secure or insecure image directories,
-regardless of the actual current delivery method. Set to 1 to force
-secure, 0 to force insecure. Note that this is not a quick way to force
-using a secure B<URL> -- just a secure directory path.
-=item sku
-Specify a sku explicitly if you want to first try an arbitrarily-named
-image in B<src>, then if it does not exist, fall back to sku-derived
-image filenames.
-=item src
-Image filename to use. May also be a plain sku, or an image basename
-which will be tried with various image suffixes (.jpg, .gif, .png, etc.)
-=item src_only
-Return only the image source location that would normally go in the
-HTML src="..." attribute of the <img> tag.
-=item title
-Text to use for the <img title="..."> attribute, used by more recent
-browsers for e.g. rollover tip text display. This attribute defaults the
-same text as the B<alt> attribute.
-=item ui
-Set this attribute to 1 to use admin UI image URL prefixes in catalog or
-global variables UI_IMAGE_DIR and UI_IMAGE_DIR_SECURE instead of regular
-catalog image prefixes from ImageDir and ImageDirSecure.
 UserTag image Routine <<EOR
 sub {
 	my ($src, $opt) = @_;
@@ -391,10 +231,8 @@
 	for (qw: width height alt title border hspace vspace :) {
 		if (defined $opt->{$_}) {
 			my $val = $opt->{$_};
-			$val = '"' . HTML::Entities::encode($val) . '"'
-				if $val =~ /\W/;
-			$val = '""' if $val eq '';
-			$opts .= qq{ $_=$val};
+			$val = HTML::Entities::encode($val) if $val =~ /\W/;
+			$opts .= qq{ $_="$val"};
 	if($opt->{extra}) {
@@ -404,3 +242,4 @@
 	return qq{<img src="$image"$opts>};

More information about the interchange-cvs mailing list