Skip to content

Commit 98fa106

Browse files
committed
fix html: Don't fail if a tag does not have some attributes.
1 parent 0735953 commit 98fa106

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

CHANGES.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ Changelog
55
1.16 (unreleased)
66
-----------------
77

8-
- Skip setting a default page if the default is already set to the same value.
8+
- fix html: Don't fail if a tag does not have some attributes.
9+
[thet]
10+
- Skip setting a default page if the default is already set to the same value.
911
[mamico]
1012
- Fixed data extraction of Archetypes ATFilefields to concatenate all `Pdata` chunks, when the FileField data was still stored in Filestorage and not not migrated to use blobstorage (using plone.app.blobs).
1113
[@jnptk]

src/collective/exportimport/fix_html.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,15 @@ def img_variant_fixer(text, obj=None, fallback_variant=None):
518518
if "data-val" not in tag.attrs:
519519
# maybe external image
520520
continue
521-
scale = tag["data-scale"]
522-
variant = scale_variant_mapping.get(scale, fallback_variant)
521+
scale = tag.get("data-scale")
522+
variant = (
523+
scale_variant_mapping.get(scale, fallback_variant)
524+
if scale
525+
else fallback_variant
526+
)
523527
tag["data-picturevariant"] = variant
524528

525-
classes = tag["class"]
529+
classes = tag.get("class", [])
526530
new_class = "picture-variant-{}".format(variant)
527531
if new_class not in classes:
528532
classes.append(new_class)

0 commit comments

Comments
 (0)