'Make a thumbnail of `website_image`'

def make_thumbnail(self):

    import requests.exceptions
    if ((not self.is_new()) and (self.website_image != frappe.db.get_value(self.doctype, self.name, u'website_image'))):
        self.thumbnail = None
    if (self.website_image and (not self.thumbnail)):
        file_doc = None
        try:
            file_doc = frappe.get_doc(u'File', {u'file_url': self.website_image, u'attached_to_doctype': u'Item', u'attached_to_name': self.name})
        except frappe.DoesNotExistError:
            pass
            frappe.local.message_log.pop()
        except requests.exceptions.HTTPError:
            frappe.msgprint(_(u'Warning:    Invalid    attachment    {0}').format(self.website_image))
            self.website_image = None
        except requests.exceptions.SSLError:
            frappe.msgprint(_(u'Warning:    Invalid    SSL    certificate    on    attachment    {0}').format(self.website_image))
            self.website_image = None
        if (self.website_image and (not file_doc)):
            try:
                file_doc = frappe.get_doc({u'doctype': u'File', u'file_url': self.website_image, u'attached_to_doctype': u'Item', u'attached_to_name': self.name}).insert()
            except IOError:
                self.website_image = None
        if file_doc:
            if (not file_doc.thumbnail_url):
                file_doc.make_thumbnail()
            self.thumbnail = file_doc.thumbnail_url
