Skip to content

Commit

Permalink
fix indexers when there is a broken preview_image_link (#91)
Browse files Browse the repository at this point in the history
* fix indexers when there is a broken preview_image_link

* changelog
  • Loading branch information
davisagli authored Sep 29, 2022
1 parent dcd44b8 commit 0a5406b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions news/91.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix hasPreviewImage and image_field indexers when the preview_image_link
relation is broken. [davisagli]
9 changes: 7 additions & 2 deletions src/plone/volto/indexers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ def hasPreviewImage(obj):
Indexer for knowing in a catalog search if a content with the IPreview behavior has
a preview_image
"""
if obj.aq_base.preview_image or obj.aq_base.preview_image_link:
if obj.aq_base.preview_image or (
obj.aq_base.preview_image_link and not obj.preview_image_link.isBroken()
):
return True
return False

Expand All @@ -23,7 +25,10 @@ def image_field_indexer(obj):
image_field = ""
if getattr(base_obj, "preview_image", False):
image_field = "preview_image"
elif getattr(base_obj, "preview_image_link", False):
elif (
getattr(base_obj, "preview_image_link", False)
and not base_obj.preview_image_link.isBroken()
):
image_field = "preview_image_link"
elif getattr(base_obj, "image", False):
image_field = "image"
Expand Down

0 comments on commit 0a5406b

Please sign in to comment.