removing imgs srcset value

master
Castro0o 5 years ago
parent 7853740b7f
commit 652d069c35

@ -67,6 +67,15 @@ def rewritelinks (html):
html = ET.tostring(t, method="html", encoding="unicode") html = ET.tostring(t, method="html", encoding="unicode")
return html return html
def rewriteimgs(html):
t = html5lib.parseFragment(html, treebuilder = "etree", namespaceHTMLElements = False)
# remove the srcset value as it prevents images from displaying
for img in t.findall(".//img[@srcset]"):
img.attrib['srcset'] = ""
html = ET.tostring(t, method="html", encoding="unicode")
return html
publish=site.Categories['Publish'] publish=site.Categories['Publish']
for cat in publish.members(): for cat in publish.members():
if cat.namespace != 14: if cat.namespace != 14:
@ -83,6 +92,8 @@ for cat in publish.members():
print(p) print(p)
htmlsrc = site.parse(page=p.name)['text']['*'] htmlsrc = site.parse(page=p.name)['text']['*']
htmlsrc = rewritelinks(htmlsrc) htmlsrc = rewritelinks(htmlsrc)
htmlsrc = rewriteimgs(htmlsrc)
if args.local is True: if args.local is True:
html = template.render(page=p, body=htmlsrc, staticpath='..') html = template.render(page=p, body=htmlsrc, staticpath='..')
else: else:

Loading…
Cancel
Save