def set_image(self): if self.source == "Image": if self.image and is_image(self.image): self.content = '<img src="{}">'.format(self.image) frappe.msgprint(frappe._("Header HTML set from attachment {0}").format(self.image), alert=True) else: frappe.msgprint( frappe._("Please attach an image file to set HTML"), alert=True, indicator="orange" )
def set_image(self): if self.source == 'Image': if self.image and is_image(self.image): self.content = '<img src="{}" style="width: 100%;">'.format( self.image) frappe.msgprint( frappe._('Header HTML set from attachment {0}').format( self.image), alert=True) else: frappe.msgprint( frappe._('Please attach an image file to set HTML'), alert=True, indicator='orange')
def get_icon_html(icon, small=False): from frappe.utils import is_image emoji_pattern = re.compile( u"(\ud83d[\ude00-\ude4f])|" u"(\ud83c[\udf00-\uffff])|" u"(\ud83d[\u0000-\uddff])|" u"(\ud83d[\ude80-\udeff])|" u"(\ud83c[\udde0-\uddff])" "+", flags=re.UNICODE) if icon and emoji_pattern.match(icon): return '<span class="text-muted">' + icon + '</span>' if is_image(icon): return \ '<img style="width: 16px; height: 16px;" src="{icon}">'.format(icon=icon) \ if small else \ '<img src="{icon}">'.format(icon=icon) else: return "<i class='{icon}'></i>".format(icon=icon)