[interchange-cvs] interchange - jon modified code/UserTag/image.tag
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Mon Jul 15 17:13:01 2002
User: jon
Date: 2002-07-15 21:12:15 GMT
Modified: code/UserTag image.tag
Log:
Added descriptionfields and exists_only options to [image].
(Documented in tag.)
Revision Changes Path
1.2 +22 -4 interchange/code/UserTag/image.tag
rev 1.2, prev_rev 1.1
Index: image.tag
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/code/UserTag/image.tag,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- image.tag 29 Jan 2002 05:52:42 -0000 1.1
+++ image.tag 15 Jul 2002 21:12:15 -0000 1.2
@@ -1,4 +1,4 @@
-UserTag image Version 0.02
+UserTag image Version 0.03
UserTag image Order src
UserTag image AddAttr
UserTag image Documentation <<EOD
@@ -51,8 +51,8 @@
=3Ditem alt
=20
Text to use for the <img alt=3D"..."> attribute. By default, this will
-be filled with the B<description> from the product database if a sku is
-provided.
+be filled with the B<description> from the product database if a sku (not
+a filename) is provided.
=20
=3Ditem default
=20
@@ -62,12 +62,25 @@
=20
Defaults to scratch mv_defaultimage if set.
=20
+=3Ditem 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.
+
=3Ditem dir_only
=20
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.
=20
+=3Ditem 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.
+
=3Ditem force
=20
Skip checking for existence of image file.
@@ -130,7 +143,11 @@
my ($src, $opt) =3D @_;
my ($image, $path, $secure, $sku);
my ($imagedircurrent, $imagedir, $imagedirsecure);
- my @descriptionfields =3D qw( description );
+
+ my @descriptionfields =3D grep /\S/, split /\s+/,
+ $opt->{descriptionfields} || $::Variable->{DESCRIPTIONFIELDS};
+ @descriptionfields =3D qw( description ) if ! @descriptionfields;
+
my @imagefields =3D qw( image );
my @imagesuffixes =3D qw( jpg gif png jpeg );
my $filere =3D qr/\.\w{2,4}$/;
@@ -253,6 +270,7 @@
}
=20
return unless $image;
+ return 1 if $opt->{exists_only};
=20
if ($opt->{getsize} and $path) {
eval {