def add_media_object(self, name, pos, w_cm, h_cm, alt="", style_name=None, crop=None): """ Overwrite base method """ self._empty = 0 size = int(max(w_cm, h_cm) * float(150.0 / 2.54)) refname = "is%s" % os.path.basename(name) imdir = self._backend.datadirfull() try: resize_to_jpeg(name, imdir + os.sep + refname, size, size, crop=crop) except: LOG.warn(_("Could not create jpeg version of image %(name)s") % {"name": name}) return if len(alt): alt = "<br />".join(alt) if pos not in ["right", "left"]: if len(alt): self.htmllist[-1] += Html("div") + ( Html("img", src=imdir + os.sep + refname, border="0", alt=alt), Html("p", class_="DDR-Caption") + alt, ) else: self.htmllist[-1] += Html("img", src=imdir + os.sep + refname, border="0", alt=alt) else: if len(alt): self.htmllist[-1] += Html("div", style_="float: %s; padding: 5px; margin: 0;" % pos) + ( Html("img", src=imdir + os.sep + refname, border="0", alt=alt), Html("p", class_="DDR-Caption") + alt, ) else: self.htmllist[-1] += Html("img", src=imdir + os.sep + refname, border="0", alt=alt, align=pos)
def add_media(self, name, pos, w_cm, h_cm, alt='', style_name=None, crop=None): """ Overwrite base method """ self._empty = 0 size = int(max(w_cm, h_cm) * float(150.0 / 2.54)) refname = "is%s" % os.path.basename(name) imdir = self._backend.datadirfull() try: resize_to_jpeg(name, imdir + os.sep + refname, size, size, crop=crop) except: LOG.warn( _("Could not create jpeg version of image %(name)s") % {'name': name}) return if len(alt): alt = '<br />'.join(alt) if pos not in ["right", "left"]: if len(alt): self.htmllist[-1] += Html('div') + (Html( 'img', src=imdir + os.sep + refname, border='0', alt=alt), Html('p', class_="DDR-Caption") + alt) else: self.htmllist[-1] += Html('img', src=imdir + os.sep + refname, border='0', alt=alt) else: if len(alt): self.htmllist[-1] += Html( 'div', style_="float: %s; padding: 5px; margin: 0;" % pos ) + (Html( 'img', src=imdir + os.sep + refname, border='0', alt=alt), Html('p', class_="DDR-Caption") + alt) else: self.htmllist[-1] += Html('img', src=imdir + os.sep + refname, border='0', alt=alt, align=pos)