[Zope] IMG attributes in ZPT

Jon Whitener wmmail@twmi.rr.com
Fri, 18 Oct 2002 16:18:54 -0400


Zopers:

How can I manipulate the attributes that are included when I insert a ZPT-rendered image tag, for CSS reasons?  (I hope there's a way to do this in the page template.)  Specifically, I want to keep the WIDTH, HEIGHT, and ALT attributes as they render dynamically, but add a CLASS attribute, and get rid of the BORDER attribute.

Currently, the ZPT code: 

  <div tal:replace="structure here/menu_icon">MENU ICON</div>

renders as:

  <img src="http://localhost:8080/menu_icon" alt="Stub Menu Icon" height="69" width="92" border="0" />

I'm glad the WIDTH and HEIGTH are included automagically, but how can I:

 - Insert a CLASS attribute, e.g. class="menu-icon"?
 - Leave out the BORDER attribute?  I don't know how that got in there.

Is there some way to add a class="menu-icon" attribute in the tag?  If I really must break it down into:

  <img src="IMG SRC" class="menu-icon" tal:attributes="src here/menu_icon/absolute_url" />

Then, how do I include the ALT, WIDTH and HEIGHT attributes into the tag, without hard-coding them?

BTW {
 I found in the docs about the

  tag(height=None, width=None, alt=None, scale=0, xscale=0, yscale=0, **args)

 method of an Image object, but I have no idea how to access or modify that stuff.  If this is necessary, please provide details.
}


Thanks in advance,
Jon Whitener
Detroit MI, USA