From 703df9c8e97f3e8e2df1b106fea616aa900a1950 2018-09-21 14:57:14 From: Brett Smith Date: 2018-09-21 14:57:14 Subject: [PATCH] Blogs/news only include a single OG image/video. For now, this gives us more assurance that other sites will choose the preview we want. You can control the selection by adding data-ogpreview to image, video, and source elements. data-ogpreview=0 excludes the element from being included in the preview. Positive numbers set the preview priority. The lowest value found is chosen first. --- diff --git a/www/conservancy/bsoup.py b/www/conservancy/bsoup.py index fb0ef6cb3d2ad50322ecc1a17f4212f713727a91..28ccdd08826e017d0e1c0303efd5a4ea2c9d66f0 100644 --- a/www/conservancy/bsoup.py +++ b/www/conservancy/bsoup.py @@ -1,6 +1,7 @@ # -*- encoding: utf-8 -*- import io +import itertools import re import bs4 @@ -86,25 +87,22 @@ class BeautifulSoup(bs4.BeautifulSoup): except AttributeError: return False - def iter_attr(self, tag, attr_name, **kwargs): - kwargs[attr_name] = True - for elem in self.find_all(tag, **kwargs): - yield elem[attr_name] + def iter_images(self): + """Return an iterator of all image elements in this document. - def iter_image_urls(self): - """Return an iterator of source URL strings of all images in this document. - - Images include tags and