[Zope] RE: Q: How can i check the existence of an image?

Ben Gustafson cbg3@earthlink.net
Fri, 4 Jan 2002 22:17:21 -0500


Hello Andreas,

This example assumes that the MyID variable gets filled somehow, such as
from the query string or form:

	<dtml-if "imgs[MyID]">
		<dtml-var "imgs[MyID]">
	</dtml-if>

Where "imgs" is the name of the folder in which the image objects are
stored. You don't need to specify the extension in your Zope image object
names, as Zope will figure out the content type when you upload the image.
The <dtml-var> tag will write out the IMG tag, including the path,
dimensions, etc., for you. If you want to add additional parameters to the
IMG tag, use <dtml-var "imgs[MyID].tag(param='myParam')"> .

--Ben

> How can I check the existence on an image file in my image folder. I
> coded a workaround, but it doesn't fit my needs exactly:
>
> <dtml-let myTemp=3Did>=20
>
> 'Build the image file name
>
> <dtml-let MyID=3D"'theme_'+myTemp+'.gif'">=20
>
>  'loop over each image in the image folder
>
> <dtml-in expr=3D"images.objectValues('Image')">
>
> ' String find
>
> <dtml-if "_.string.find(id(),MyID) > -1">=20
>
> ' -> if there is a matching file print image in HTML
> <img src=3D"/images/<dtml-var id>" width=3D"145" height=3D"129"> 'print =
> image
> in HTML
>
> </dtml-if>
> </dtml-in>
> </dtml-let>
> </dtml-let>
>
> ...but I'm looking for something like this:
>
> 'check if true or not
> <dtml-in expr=3D"images.<image_name>">=20