0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-07-06 03:08:58 +02:00

Handle floats as img widths

This commit is contained in:
Erik Johnston 2016-06-15 16:58:05 +01:00
parent a60169ea09
commit 1e9026e484

View file

@ -280,7 +280,7 @@ class PreviewUrlResource(Resource):
# TODO: consider inlined CSS styles as well as width & height attribs
images = tree.xpath("//img[@src][number(@width)>10][number(@height)>10]")
images = sorted(images, key=lambda i: (
-1 * int(i.attrib['width']) * int(i.attrib['height'])
-1 * float(i.attrib['width']) * float(i.attrib['height'])
))
if not images:
images = tree.xpath("//img[@src]")