[ZCM] [ZC] 634/ 4 Resolve "Image objects return img element with deprecated border attribute"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin@zope.org
Sun, 02 Feb 2003 07:25:49 -0500


Issue #634 Update (Resolve) "Image objects return img element with deprecated border attribute"
 Status Resolved, Zope/bug medium
To followup, visit:
  http://collector.zope.org/Zope/634

==============================================================
= Resolve - Entry #4 by ajung on Feb 2, 2003 7:25 am

 Status: Pending => Resolved

Applied Maiks solution using "image.tag(border='')" to the 
HEAD.


________________________________________
= Comment - Entry #3 by mjablonski on Dec 20, 2002 6:47 pm

I suggest the following patch to lib/python/OFS/Image.py. If an additional argument is empty, it shouldn't be rendered at all!

783c783,784
<             result = '%s %s="%s"' % (result, key, value)
---
>             if value:
>                 result = '%s %s="%s"' % (result, key, value)

Then you can use ImageObject.tag(border='') and receive an image-tag without the border-element.

________________________________________
= Comment - Entry #2 by tfarrell on Oct 21, 2002 11:01 am

Please read the associated thread on the zope@zope.org mailing list:
http://lists.zope.org/pipermail/zope/2002-October/125010.html
________________________________________
= Request - Entry #1 by tfarrell on Oct 21, 2002 10:55 am

When calling a Zope Image object, the object returns a string.  This string is an html img element in the form of the following:

<img src="picture.jpg" width="1" height="1" alt="A picture" border="0" />

This element represents an ugly hybrid.  The border attribute is deprecated in HTML 4.01, tolerated in XHTML 1.0 Transitional and not allowed in XHTML 1.0 Strict.  The / at the end of the element is an attempt at XML validity (presumably to allow us to use the element in XHTML pages.)

The offending border attribute is added in lines 766 and 767 of /lib/python/OFS/Image.py(http://cvs.zope.org/~checkout~/Zope/lib/python/OFS/Image.py?rev=1.141.2.2&content-type=text/plain)

if not 'border' in [ x.lower() for x in  args.keys()]:
  result = '%s border="0"' % result

It was suggested by Casey that we allow the border attribute to be omited by calling the method with a special parameter.  Below is his email:

Please file a collector issue for this.

The border is there by default because most browsers put a border around images when they are inside an anchor tag. Since most of the time people did not want this, they requested this feature.

A couple of fixes come to mind, like adding a "no_border" argument, or allow "border=''" to mean omit that attribute. Some other thoughts include adding a new "xtag" method that generates XHTML strict or a configuration option that tells Zope to generate strict code.

==============================================================