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

def CMFPhoto::Photo::Photo::tag (   self,
  height = None,
  width = None,
  alt = None,
  scale = 0,
  xscale = 0,
  yscale = 0,
  css_class = None,
  title = None,
  size = 'original',

Return an HTML img tag (See OFS.Image)

Definition at line 242 of file Photo.py.

        """ Return an HTML img tag (See OFS.Image)"""

        # Default values

        if height is None or width is None:

            if size in self.photo_display_sizes().keys():
                if not self._photos.has_key(size):
                    # This resized image isn't created yet.
                    # Calculate a size for it
                    x,y = self.photo_display_sizes().get(size)
                    tmpw, tmph = self.width, self.height
                        mirror, rotation = self.exif_orientation()
                        if rotation == 90 or rotation == 270:
                            tmpw, tmph = tmph, tmpw
                        if tmpw > tmph:
                            w = x
                            h = int(round(1.0/(float(tmpw)/w/tmph)))
                            h = y
                            w = int(round(1.0/(float(tmph)/x/tmpw)))
                    except ValueError:
                        # OFS.Image only knows about png, jpeg and gif.
                        # Other images like bmp will not have height and
                        # width set, and will generate a ValueError here.
                        # Everything will work, but the image-tag will render
                        # with height and width attributes.
                    # The resized image exist, get it's size
                    photo = self._photos.get(size)

        if height is None: height=h
        if width is None:  width=w

        # Auto-scaling support
        xdelta = xscale or scale
        ydelta = yscale or scale

        if xdelta and width:
            width =  str(int(round(int(width) * xdelta)))
        if ydelta and height:
            height = str(int(round(int(height) * ydelta)))

        result='<img src="%s/variant/%s"' % (self.absolute_url(), escape(size))

        if alt is None:
            alt=getattr(self, 'title', '')
        result = '%s alt="%s"' % (result, escape(alt, 1))

        if title is None:
            title=getattr(self, 'title', '')
        result = '%s title="%s"' % (result, escape(title, 1))

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

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

        if not 'border' in [ x.lower() for x in  args.keys()]:
            result = '%s border="0"' % result

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

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

        return '%s />' % result

    security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'doTransform')
    def doTransform(self, method, REQUEST=None):

Generated by  Doxygen 1.6.0   Back to index