Can we disable Image Option --> Contact

Hello Team,
Can we remove the image that will auto populate when email is added ?

Ref Code:
def get_gravatar_url(email: str, default: Literal[“mm”, “404”] = “mm”) → str:
hexdigest = hashlib.md5(frappe.as_unicode(email).encode(“utf-8”), usedforsecurity=False).hexdigest()
return f"https://secure.gravatar.com/avatar/{hexdigest}?d={default}&s=200"

init.py

Reference Doctype: Contact

Any configurations we have?

Hello @Prasanth_Kumar_J

Open Customize form of Contact
In the setting there is form setting, Remove the fieldname form the “Image Field”

image

By doing this, the preview of image in the left bar is removed

Got it thanks it will remove that image option.

but for some contact we may require and for some we may not.
So in our case where image not required if we are removing it was re uploading again.

Hi @Prasanth_Kumar_J

Open Customize form of Contract and Create a new field name: Image Not Required, fieldtype: Check

In the code change image_not_required with your fieldname

frappe.ui.form.on('Contact', {
    before_save(frm){
        if(frm.doc.image_not_required == 1){
            frm.set_value("image"," ");
        }
    }
})

So, when this checkbox is checked then url in the image file changed with " " this. and preview will be gone.

1 Like

Yeah
thanks done through Python Code

Was checking for if any configuration exists

@Usama_Naveed

One quick question any idea on what basis the image will be fetched for the contact?

@Prasanth_Kumar_J

Sure, Let me explain

In the contact.py, the has_gravatar function call from frappe.utils to fetch image.

has_gravatar function exist in apps/frappe/frappe/utils/init.py

If the email account is correct and have profile image then this https://secure.gravatar.com/ website return the gravatar url. By this url image will be load in the contact doctype, User Doctype, and Lead doctype.

Sure thanks
Code wise I understood but I had this query from where it will be fetched.

But according to you if the email account has image then will be fetched else not. I have image to my account but no image was displayed.

Check email address is correct entered?

Maybe some space exist

It is correct,
FYI: Used email → jprasanthkumar28@gmail.com

You’re right, Image not populating on this email I tested.

I tested on my email also, it’s working

fine thanks