In our last episode,
<1111185226.482808.310950 (AT) l41g2000cwc (DOT) googlegroups.com>,
the lovely and talented nzanella (AT) cs (DOT) mun.ca
broadcast on comp.infosystems.
www.authoring.stylesheets: Quote:
Hello,
I would like to know whether it is possible to use cascading
style sheet language to set the values of the src and alt
attributes of an img tag. This would come in handy in
situations where you want to display an image in
several places by referencing it by its class
attribute for conciseness. |
Not really. You can put the image in a stylesheet by making it
the background of a box and simulate an alt text with text in
your document that you hide. And this can actually be sort of
seamless-looking in text browsers.
But what you really want is not to be typing the
IMG tag in over and over. What you want is a preprocessor.
Here is how I enter am image (one I call shortname for this
example) in my preprocessed document:
%getimage(%location,shortname,&pagereg)
This is simpler than that, because I taught my editor a macro
to prompt me for the shortname when I hit meta-q g, and it
writes the line. The preprossor looks up shortname in a
database of images, writes the IMG tag, writes the markup
and caption (if there is a caption in the database) and
records the use of the image in a text file which will be
used by macros in the footer to lookup the photo credit
to put it in the footer and in the stylesheet to look up
height, width, and any special styles for the image. Naturally
the footer gets preprocessed after the body of the document,
and the only tricky thing is to be sure the stylesheet is
in the Makefile *after* the document.
%location is a variable I set at the top of every document
that says where the document is. The %getimage preprocessor
macro then will get the path in the IMG src attribute right
no matter what directory the document is in.
Preprocessor.
--
Lars Eighner eighner (AT) io (DOT) com
http://www.larseighner.com/
Nobody home but the lights, and they're out too.