Skip to content

Commit acf82b5

Browse files
authored
Merge pull request #277 from collective/thet/fix-html-fixes
fix html: Don't fail if a tag does not have some attributes.
2 parents 51fd6b6 + 90b1861 commit acf82b5

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Changelog
77

88
- Notify the comment creation to have them indexed in the catalog
99
[erral]
10+
- fix html: Don't fail if a tag does not have some attributes.
11+
[thet]
1012
- Skip setting a default page if the default is already set to the same value.
1113
[mamico]
1214
- 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).

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)