Show thumbnail image in daily work summary (#10605)

* Show thumbnail image in daily work summary

* Crop thumbnail image into square

* fix codacy
This commit is contained in:
Faris Ansari 2017-09-18 16:58:24 +05:30 committed by Rushabh Mehta
parent e78d5a240a
commit aebcb17daf

View File

@ -52,6 +52,25 @@ class DailyWorkSummary(Document):
d.sender_name = emp[0].employee_name if emp else d.sender d.sender_name = emp[0].employee_name if emp else d.sender
d.image = emp[0].image if emp and emp[0].image else None d.image = emp[0].image if emp and emp[0].image else None
original_image = d.image
# make thumbnail image
try:
if original_image:
file_name = frappe.get_list('File', {'file_url': original_image})
if file_name:
file_name = file_name[0].name
file_doc = frappe.get_doc('File', file_name)
thumbnail_image = file_doc.make_thumbnail(
set_as_thumbnail=False,
width=100,
height=100,
crop=True
)
d.image = thumbnail_image
except:
d.image = original_image
if d.sender in did_not_reply: if d.sender in did_not_reply:
did_not_reply.remove(d.sender) did_not_reply.remove(d.sender)
if d.text_content: if d.text_content: