fix: Check if file exists before generating base64

This commit is contained in:
Faris Ansari 2020-09-11 19:22:34 +05:30
parent 85a3a8bd35
commit cc9fdd690a

View file

@ -746,6 +746,7 @@ def is_image(filepath):
return (guess_type(filepath)[0] or "").startswith("image/")
def get_thumbnail_base64_for_image(src):
from os.path import exists as file_exists
from PIL import Image
from frappe.core.doctype.file.file import get_local_image
from frappe import safe_decode, cache
@ -760,6 +761,10 @@ def get_thumbnail_base64_for_image(src):
return
def _get_base64():
file_path = frappe.get_site_path("public", src.lstrip("/"))
if not file_exists(file_path):
return
try:
image, unused_filename, extn = get_local_image(src)
except IOError: