Beispiel #1
0
 def get_description_display(self, device):
     html = etree.fromstring('<div>%s</div>' % self.description, parser=etree.HTMLParser())
     for img in html.findall('.//img'):
         eis = resize_external_image(img.attrib['src'], device.max_image_width-40)
         img.attrib['src'] = eis.get_absolute_url()
         img.attrib['width'] = '%d' % eis.width
         img.attrib['height'] = '%d' % eis.height
     return etree.tostring(html.find('.//div'), method="html")[5:-6]
Beispiel #2
0
 def handle_GET(self, request, context, slug):
     try:
         eis = resize_external_image(
             context['webcam'].url,
             request.map_width, timeout=5)
     except:
         eis = None
     
     context['eis'] = eis
     return self.render(request, context, 'webcams/webcam_detail')
    def render(self, context):
        try:
            width = int(self.max_width.resolve(context))
        except Exception:
            width = float('inf')
            
        url, width = self.url.resolve(context), min(width, context['device'].max_image_width)

        eis = resize_external_image(url, width)

        if not eis:
            return ''
        elif self.just_url:
            return eis.get_absolute_url()
        else:
            return """<div class="backgrounded-image" style="background-image:url('%s'); height:%dpx"> </div>""" % (eis.get_absolute_url(), eis.height)