Skip to content

Commit a13acc1

Browse files
authored
Check that image_obj is there and has a file before generating a URL. (#2950)
1 parent 7642af8 commit a13acc1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cms/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ def ensure_instructors_index() -> cms_models.InstructorIndexPage:
267267

268268
def get_wagtail_img_src(image_obj) -> str:
269269
"""Returns the image source URL for a Wagtail Image object"""
270+
if not image_obj or not image_obj.file:
271+
return ""
272+
270273
root_rel = urljoin(settings.MEDIA_URL, image_obj.file.name)
271274
abs_url = urljoin(settings.SITE_BASE_URL, root_rel)
272275
return (

0 commit comments

Comments
 (0)