def extract_images(self): from frappe.utils.file_manager import extract_images_from_html if self.format_data: data = json.loads(self.format_data) for df in data: if df.get('fieldtype') and df['fieldtype'] in ('HTML', 'Custom HTML') and df.get('options'): df['options'] = extract_images_from_html(self, df['options']) self.format_data = json.dumps(data)
def add_comment(reference_doctype, reference_name, content, comment_email, comment_by): """allow any logged user to post a comment""" doc = frappe.get_doc( dict(doctype='Comment', reference_doctype=reference_doctype, reference_name=reference_name, comment_email=comment_email, comment_type='Comment', comment_by=comment_by)) doc.content = extract_images_from_html(doc, content) doc.insert(ignore_permissions=True) follow_document(doc.reference_doctype, doc.reference_name, frappe.session.user) return doc.as_dict()
def _extract_images_from_text_editor(self): from frappe.utils.file_manager import extract_images_from_html if self.doctype != "DocType": for df in self.meta.get("fields", {"fieldtype": "Text Editor"}): extract_images_from_html(self, df.fieldname)
def _extract_images_from_text_editor(self): from frappe.utils.file_manager import extract_images_from_html if self.doctype != "DocType": for df in self.meta.get("fields", {"fieldtype":"Text Editor"}): extract_images_from_html(self, df.fieldname)