[Zope] Re: Please help with Rendering Images in DTML

Gary Speer gspeer@cortech.org
Tue, 28 Jan 2003 18:39:31 -0700


Thank you for the suggestion.  Unfortunately I cannot get past an 'Attribute
Error' on ___GetItem___.
If the arguement of restricted traverse is a quoted string as in your
example, it works.
What I need to pass is a variable that contains that string and have it
rendered.
For example, your suggested:
<dtml-with "restrictedTraverse('folder/subfolder/myimage.jpg')">
<dtml-var title_or_id>: <dtml-var height>, <dtml-var width>
</dtml-with>

works, but

With request setting QUERY_STRING = "myimage.jpg"

<dtml-let "MyImage='folder/subfolder/'+QUERY_STRING")
<dtml-with "restrictedTraverse(MyImage)">
<dtml-var title_or_id>: <dtml-var height>, <dtml-var width>
</dtml-with>
</dtml-let>

generates the attribute error on GetItem
Any ideas?
Thanks,
Gary

----- Original Message -----
From: "Maik Jablonski" <maik.jablonski@uni-bielefeld.de>
Newsgroups: gmane.comp.web.zope.general
To: "Gary Speer" <gspeer@cortech.org>
Sent: Sunday, January 26, 2003 6:58 AM
Subject: Re: Please help with Rendering Images in DTML


Gary Speer wrote:
> In a DTML method, a string is constructed in a variable that is the
relative
> URL of an Image.
> For example ...
> <dtml-let MyImageId="'folder/subfolder/myimage.jpg'">
>
> using
> <dtml-var MyImageId>  results in just the string being returned
> a hand constructed image tag like
> <img src=<dtml-var MyImageID> alt="">
> will render the desired image, but does not provide access to its 'Image
> object' attributes like height and width.

Hi,

you can get every object via an url with restrictedTraverse. Then you
can access the properties of the object...

Example:

<dtml-with "restrictedTraverse('folder/subfolder/myimage.jpg')">
<dtml-var title_or_id>: <dtml-var height>, <dtml-var width>
</dtml-with>

Cheers, Maik