'Validate if the website image is a public file'

def validate_website_image(self):

    auto_set_website_image = False
    if ((not self.website_image) and self.image):
        auto_set_website_image = True
        self.website_image = self.image
    if (not self.website_image):
        return
    file_doc = frappe.get_all(u'File', filters={u'file_url': self.website_image}, fields=[u'name', u'is_private'], order_by=u'is_private    asc', limit_page_length=1)
    if file_doc:
        file_doc = file_doc[0]
    if (not file_doc):
        if (not auto_set_website_image):
            frappe.msgprint(_(u'Website    Image    {0}    attached    to    Item    {1}    cannot    be    found').format(self.website_image, self.name))
        self.website_image = None
    elif file_doc.is_private:
        if (not auto_set_website_image):
            frappe.msgprint(_(u'Website    Image    should    be    a    public    file    or    website    URL'))
        self.website_image = None
