diff --git a/frappe/templates/print_formats/standard_macros.html b/frappe/templates/print_formats/standard_macros.html index 7a0dce7f5e..b728a1a291 100644 --- a/frappe/templates/print_formats/standard_macros.html +++ b/frappe/templates/print_formats/standard_macros.html @@ -126,14 +126,14 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}" {% include doc.print_templates[df.fieldname] %} {% elif df.fieldtype=="Check" %} - {% elif df.fieldtype in ("Image", "Attach Image") %} + {% elif df.fieldtype in ("Image", "Attach Image") and frappe.utils.is_image(doc[doc.meta.get_field(df.fieldname).options]) %} {% elif df.fieldtype=="Signature" %} - {% elif df.fieldtype == "Attach" and doc[df.fieldname] and frappe.utils.is_image(doc[df.fieldname]) %} + {% elif df.fieldtype == "Attach" and frappe.utils.is_image(doc[df.fieldname]) %} {% elif df.fieldtype=="HTML" %} diff --git a/frappe/utils/data.py b/frappe/utils/data.py index da2c910e20..e9bfc4ae26 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -824,7 +824,7 @@ def is_image(filepath): from mimetypes import guess_type # filepath can be https://example.com/bed.jpg?v=129 - filepath = filepath.split('?')[0] + filepath = (filepath or "").split('?')[0] return (guess_type(filepath)[0] or "").startswith("image/") def get_thumbnail_base64_for_image(src):