[Zope] Re: using ImageTag_Hotfix

marc lindahl marc@bowery.com
Fri, 19 Oct 2001 12:20:05 -0400


Hi John,
I'm cc'ing this back to the list...

> Hi, I have been using the thumbnail hotfix and am having trouble
> getting the functions to use cacheable thumbnails.

I put what I *think* is the right stuff to let the thumbs be cacheable by a
RAMcache, but so far my cries for help on the subject, and documentation for
how to take advantage of RAMcache, have been unanswered, so I don't know if
that works.  But the http tags for letting the client browser cache the
images are working.

> 
> I have been reading __init__.py to get some understanding of how to
> use this code.  Currently, I have a simple DTML script to iterate over
> a Folder and make thumbnails of each image in the folder with links to
> the original.

I'll paste the relevant code from my CMFPhotoAlbum product, which I know
works:

<dtml-in "objectItems(['Image','Portal Image'])" sort=id size=qsize
start=qstart>
<dtml-if "(_['sequence-index']%5)==0">
</tr>
<tr>
</dtml-if>
<td valign=bottom align=center>


<a href="<dtml-var "_['sequence-key']+'/viewimg?img='+_['sequence-key']">">
<dtml-var "title_or_id()"><br>
<dtml-with stylesheet_properties>
<dtml-var "tag(width=80, height='',border=2, style='border-color:' +
base_font_color + 
            ';background-color:' + base_font_color)">
</dtml-with>
</a>

</td>
</dtml-in>



> If I read this correctly, this is *not* using the function 'thumb'
> that is defined in __init__.py, but is using the browser to resize the
> images.  The problem with this, of course, is that if you have a lot
> of images and want to frequently reload the page, it can be slow.

...exactly why I made this product!

> 
> I that source code for 'tag' used the logic 'if height and width are
> integers call thumb, e

that's correct.

>lse use the height and width attributes of
> html'.  The function 'thumb' calls:
> 
> thumbnail_file = self.ZCacheable_get(view_name='thumb', keywords=keys)
> 
> so it appears to me that this is thumbnail cacheing, which is the
> behavior I want.

this is the stuff to use an external RAMcache.  The idea is that you would
have one RAMcache on your site to cache your calculated thumbnails.
Architecturally, that's usually what you'd want.  The part I dont' know is,
how could you get any newly created image to connect to this RAMCache
automatically?  Right now, it seems to work if you create the image and the
RAMcache and associate it manually via the ZMI, but what a pain!  I wish I
knew how to do this within the product - e.g. associate the 'class' with the
RAMcache....


> 
> My question is: how should I code the DTML so I can get the thumbnail
> cacheing?  I tried manually setting height and width to integer values
> but this did not help:
> 
> <dtml-var "this().tag(40,60)"></a>
> 
> Is this because '40' and '60' here are not really integers but strings
> by the time they get passed to 'tag'?
> 
> Ideally, I would like to generated scaled, cached thumbnails.

one thing you can try is naming the attributes?  tag(height=60,width=40),
something like that....

You can see in the source that index_html generates the cacheable http
headers, which will activate downstream caches.... it might even help a
downstream Squid -- if anyone knows for sure, or has suggestions in that
area, let me know!

Marc