def fImage(self, match): # (None, '', '/imgs/myphoto.jpg', None, None) align, atts, url, title, href = match.groups() atts = self.pba(atts) if align: atts = atts + ' style="%s"' % self.iAlign[align] if title: atts = atts + ' title="%s" alt="%s"' % (title, title) else: atts = atts + ' alt=""' if not self.isRelURL(url) and self.get_sizes: size = imagesize.getimagesize(url) if size: atts += " %s" % size if href: href = self.checkRefs(href) url = self.checkRefs(url) url = self.relURL(url) out = [] if href: out.append('<a href="%s" class="img">' % href) if self.html_type == 'html': out.append('<img src="%s"%s>' % (url, atts)) else: out.append('<img src="%s"%s />' % (url, atts)) if href: out.append('</a>') return ''.join(out)
def test_imagesize(): assert getimagesize("http://www.google.com/intl/en_ALL/images/logo.gif") == (276, 110) assert getimagesize("http://bad.domain/") == '' assert getimagesize("http://www.google.com/robots.txt") is None
def test_imagesize(): assert getimagesize( "http://www.google.com/intl/en_ALL/images/logo.gif") == (276, 110) assert getimagesize("http://bad.domain/") == '' assert getimagesize("http://www.google.com/robots.txt") is None