[Zope] Extensions to Image object

Nico de Boer nico@nfg.nl
12 Feb 2002 16:33:24 +0100


Good afternoon,

I'm trying to make an image object with a description. I have done
this in Python code, but now I want to make this in DTML.

The method that I've used in Python goes like this:

    def index_html(self,PARENTS,REQUEST):
        """Extension of img_src to allow  textual elements"""
        return self.render(PARENTS,REQUEST)

    def img_src(self, REQUEST, RESPONSE):
        """
        The default view of the contents of a File or Image.
        Returns the contents of the file or image (raw data).  Also, sets the
        Content-Type HTTP header to the objects content type.
        """
        return Image.index_html(self, REQUEST, RESPONSE)

    def render(self, PARENTS, REQUEST=None, RESPONSE=None, height=None, width=None,
               alt=None, title=None, scale=0, xscale=0, yscale=0,
               css_class=None, **args):
        """Extension of img tag to allow textual elements"""
        args["height"]=height
        args["width"]=width
        args["alt"]=alt
        args["scale"]=scale
        args["xscale"]=xscale
        args["yscale"]=yscale
        args["css_class"]=css_class
        
        return '%s<br>%s' % (
            apply(self.img_tag,(),args),
            self.text    
            )

Does anyone know a simple way to do this in DTML, probably with a
ZClass? 

Thanks a lot,

Greetz Nico