Logo Search packages:      
Sourcecode: zope-photo version File versions  Download package

def zope-photo-1.2.4::Photo::Photo::tag (   self,
  display = None,
  height = None,
  width = None,
  cookie = 0,
  alt = None,
  css_class = None,

Return HTML img tag.

Definition at line 138 of file Photo.py.

        """Return HTML img tag."""

        # Get cookie if display is not specified.
        if display is None:
            display = self.REQUEST.cookies.get('display', None)

        # display may be set from a cookie.
        if display is not None and self._displays.has_key(display):
            if not self._isGenerated(display):
                # Generate photo on-the-fly
                self._makeDisplayPhoto(display, 1)
            image = self._photos[display]
            width, height = (image._width(), image._height())
            # Set cookie for chosen size
            if cookie:
                self.REQUEST.RESPONSE.setCookie('display', display, path="/")
            # TODO: Add support for on-the-fly resize?
            height = self._original._height()
            width = self._original._width()

        if display:
            result = '<img src="%s?display=%s"' % (self.absolute_url(), display)
            result = '<img src="%s"' % (self.absolute_url())

        if alt is None:
            alt = getattr(self, 'title', '')
        if alt == '':
            alt = self.getId()
        result = '%s alt="%s"' % (result, html_quote(alt))

        if height:
            result = '%s height="%s"' % (result, height)

        if width:
            result = '%s width="%s"' % (result, width)

        if not 'border' in map(string.lower, kw.keys()):
            result = '%s border="0"' % (result)

        if css_class is not None:
            result = '%s class="%s"' % (result, css_class)

        for key in kw.keys():
            value = kw.get(key)
            result = '%s %s="%s"' % (result, key, value)

        result = '%s />' % (result)

        return result

    security.declareProtected('View', 'exttag')
    def exttag(self, prefix, display=None, height=None, width=None, cookie=0,

Generated by  Doxygen 1.6.0   Back to index