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
Jon, I'm hear to second your request. I got sick of the blatant XHTML standards violation here, so I edited Image.py, commenting out lines 748 and 749. Anyway, that fixes the direct call method. I got sick of editing source code for all the installs (and to lazy to make a HotFix/Monkey Patch - religous debate anyone?), so for ZPT, I started using this when I didn't want to hard code it: <img tal:define="image python:getattr(here.img,'guests_logo.png')" tal:attributes="src image/absolute_url; height image/height; width image/width; alt image/title_or_id" style="border: 0;"> This works for an image guests_logo.png stored in a subfolder img. HTH, Troy Jon Whitener wrote:
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
Ouch. No one bothered to correct my violation of the English language. I'm here to second your request. Troy Farrell wrote:
Jon, I'm hear to second your request. I got sick of the blatant XHTML standards violation here, so I edited Image.py, commenting out lines 748 and 749. Anyway, that fixes the direct call method. I got sick of editing source code for all the installs (and to lazy to make a HotFix/Monkey Patch - religous debate anyone?), so for ZPT, I started using this when I didn't want to hard code it:
<img tal:define="image python:getattr(here.img,'guests_logo.png')" tal:attributes="src image/absolute_url; height image/height; width image/width; alt image/title_or_id" style="border: 0;">
This works for an image guests_logo.png stored in a subfolder img.
HTH, Troy
On Fri, Oct 18, 2002 at 04:18:54PM -0400, Jon Whitener wrote:
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.
<div tal:replace="structure python:here.menu_icon.tag(class='menu-icon')" /> The tag() method of the image will put in height, width and alt itself, and also includes any arguments you give it as attributes in the IMG tag.
I'm glad the WIDTH and HEIGTH are included automagically, but how can I: - Leave out the BORDER attribute? I don't know how that got in there.
You can't with image_object.tag(), but border=0 is a fairly harmless default, isn't it? Felix.
It's only harmless if you don't validate your XHTML (http://validator.w3.org/check/) or you aren't trying to convert a site to XHTML. HTML 4.01 says the border attribute is deprecated. http://www.w3.org/TR/html401/struct/objects.html#adef-border-IMG XHTML 1.0 Transitional DTD allows it as well: <!ELEMENT img EMPTY> <!ATTLIST img %attrs; src %URI; #REQUIRED alt %Text; #REQUIRED name NMTOKEN #IMPLIED longdesc %URI; #IMPLIED height %Length; #IMPLIED width %Length; #IMPLIED usemap %URI; #IMPLIED ismap (ismap) #IMPLIED align %ImgAlign; #IMPLIED border %Length; #IMPLIED hspace %Pixels; #IMPLIED vspace %Pixels; #IMPLIED
but the XHTML 1.0 Strict DTD doesn't allow the border attribute: <!ELEMENT img EMPTY> <!ATTLIST img %attrs; src %URI; #REQUIRED alt %Text; #REQUIRED longdesc %URI; #IMPLIED height %Length; #IMPLIED width %Length; #IMPLIED usemap %URI; #IMPLIED ismap (ismap) #IMPLIED
Troy Felix Ulrich-Oltean wrote:
On Fri, Oct 18, 2002 at 04:18:54PM -0400, Jon Whitener wrote:
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.
<div tal:replace="structure python:here.menu_icon.tag(class='menu-icon')" />
The tag() method of the image will put in height, width and alt itself, and also includes any arguments you give it as attributes in the IMG tag.
I'm glad the WIDTH and HEIGTH are included automagically, but how can I: - Leave out the BORDER attribute? I don't know how that got in there.
You can't with image_object.tag(), but border=0 is a fairly harmless default, isn't it?
Felix.
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. -Casey On Mon, 21 Oct 2002 08:21:39 -0500 Troy Farrell <troy@entheossoft.com> wrote:
It's only harmless if you don't validate your XHTML (http://validator.w3.org/check/) or you aren't trying to convert a site to XHTML.
HTML 4.01 says the border attribute is deprecated. http://www.w3.org/TR/html401/struct/objects.html#adef-border-IMG
XHTML 1.0 Transitional DTD allows it as well:
<!ELEMENT img EMPTY> <!ATTLIST img %attrs; src %URI; #REQUIRED alt %Text; #REQUIRED name NMTOKEN #IMPLIED longdesc %URI; #IMPLIED height %Length; #IMPLIED width %Length; #IMPLIED usemap %URI; #IMPLIED ismap (ismap) #IMPLIED align %ImgAlign; #IMPLIED border %Length; #IMPLIED hspace %Pixels; #IMPLIED vspace %Pixels; #IMPLIED
but the XHTML 1.0 Strict DTD doesn't allow the border attribute:
<!ELEMENT img EMPTY> <!ATTLIST img %attrs; src %URI; #REQUIRED alt %Text; #REQUIRED longdesc %URI; #IMPLIED height %Length; #IMPLIED width %Length; #IMPLIED usemap %URI; #IMPLIED ismap (ismap) #IMPLIED
Troy
Felix Ulrich-Oltean wrote:
On Fri, Oct 18, 2002 at 04:18:54PM -0400, Jon Whitener wrote:
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.
<div tal:replace="structure python:here.menu_icon.tag(class='menu-icon')" />
The tag() method of the image will put in height, width and alt itself, and also includes any arguments you give it as attributes in the IMG tag.
I'm glad the WIDTH and HEIGTH are included automagically, but how can I: - Leave out the BORDER attribute? I don't know how that got in there.
You can't with image_object.tag(), but border=0 is a fairly harmless default, isn't it?
Felix.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Done. Bug #634. Casey Duncan wrote:
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.
-Casey
On Mon, 21 Oct 2002 08:21:39 -0500 Troy Farrell <troy@entheossoft.com> wrote:
It's only harmless if you don't validate your XHTML (http://validator.w3.org/check/) or you aren't trying to convert a site to XHTML.
HTML 4.01 says the border attribute is deprecated. http://www.w3.org/TR/html401/struct/objects.html#adef-border-IMG
XHTML 1.0 Transitional DTD allows it as well:
<!ELEMENT img EMPTY> <!ATTLIST img %attrs; src %URI; #REQUIRED alt %Text; #REQUIRED name NMTOKEN #IMPLIED longdesc %URI; #IMPLIED height %Length; #IMPLIED width %Length; #IMPLIED usemap %URI; #IMPLIED ismap (ismap) #IMPLIED align %ImgAlign; #IMPLIED border %Length; #IMPLIED hspace %Pixels; #IMPLIED vspace %Pixels; #IMPLIED
but the XHTML 1.0 Strict DTD doesn't allow the border attribute:
<!ELEMENT img EMPTY> <!ATTLIST img %attrs; src %URI; #REQUIRED alt %Text; #REQUIRED longdesc %URI; #IMPLIED height %Length; #IMPLIED width %Length; #IMPLIED usemap %URI; #IMPLIED ismap (ismap) #IMPLIED
Troy
Felix Ulrich-Oltean wrote:
On Fri, Oct 18, 2002 at 04:18:54PM -0400, Jon Whitener wrote:
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.
<div tal:replace="structure python:here.menu_icon.tag(class='menu-icon')" />
The tag() method of the image will put in height, width and alt itself, and also includes any arguments you give it as attributes in the IMG tag.
I'm glad the WIDTH and HEIGTH are included automagically, but how can I: - Leave out the BORDER attribute? I don't know how that got in there.
You can't with image_object.tag(), but border=0 is a fairly harmless default, isn't it?
Felix.
On Mon, 2002-10-21 at 10:05, Casey Duncan wrote:
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.
-Casey
<imho> I would love to see Zope generate nothing but strict code and allow web developers the ability to degrade it if they have a need. Features are great, but standards need to be fully implemented first. Imagine if it was that way throughout the web. </imho>
On 21 Oct 2002 13:22:12 -0400 Jesse Goerz <jgoerz@cfl.rr.com> wrote: [snip]
<imho> I would love to see Zope generate nothing but strict code and allow web developers the ability to degrade it if they have a need. Features are great, but standards need to be fully implemented first. Imagine if it was that way throughout the web. </imho>
Bear in mind that the "border" attribute *was* part of the standard and has been later taken out. When this was implemented, XHTML strict was not yet a standard. IMO Zope does its best to implement and adhere to standards. And it is appreciated when people point out the places where it doesn't. -Casey
Felix: Thanks for the guidance. As far as the border=0 default IMG attribute, I worry that at some point, it will conflict with a stylesheet. Thanks again, Jon At 10/21/02 03:49 AM, Felix Ulrich-Oltean wrote:
On Fri, Oct 18, 2002 at 04:18:54PM -0400, Jon Whitener wrote:
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.
<div tal:replace="structure python:here.menu_icon.tag(class='menu-icon')" />
The tag() method of the image will put in height, width and alt itself, and also includes any arguments you give it as attributes in the IMG tag.
I'm glad the WIDTH and HEIGTH are included automagically, but how can I: - Leave out the BORDER attribute? I don't know how that got in there.
You can't with image_object.tag(), but border=0 is a fairly harmless default, isn't it?
Felix.
participants (5)
-
Casey Duncan -
Felix Ulrich-Oltean -
Jesse Goerz -
Jon Whitener -
Troy Farrell