Employee photo in a HTML custom block

Hi there,

Im new in Frappe world. Im having some issues trying to add an employee photo in a HTML custom block.

I tried this:

HTML:

<img id="imageUser" class="user-image" alt="Imagen de Usuario">

JS:

const urlParams = new URLSearchParams(window.location.search);
const imageUser = urlParams.get('imageUser');
document.getElementById('imageUser').src = imageUser;`Preformatted text`
type or paste code here

But I only get this:
imagen_2024-09-26_172954869

Could someone give me some help, please?
Thanks in advance.

Hernán

first, you have to get the employee image.

Please check the example and how it works the Custom HTML Block: How to use custom html block - #7 by NCP

Hi @NCP
Thanks for your help.

I checked your explanation, but I couldnt get the image.
Here is what a tried:

HTML

<div id="imageuser2"></div>

JS

frappe.call({
    method: "frappe.client.get",
        args: {
            doctype: "User",
            name: frappe.session.user,
             },
             callback(r) {
                 if(r.message) {
                    root_element.querySelector('#imageUser').textContent=r.imageuser2;
                 }
             }
});

Is there a minor error or isnt the way to get de user image?
Thanks again

Check your selector, it doesn’t match your container’s id. Also why are you changing the text content?

Hi @Yamen_Zakhour, thanks for your answer.

I update the selector to match with container ID, but it still not working.
About your question, I dont have an answer, as I said later, Im not experienced with frappe nor js, so Im just trying.

HTML

<div id="imageUser"></div>

JS

frappe.call({
    method: "frappe.client.get",
        args: {
            doctype: "User",
            name: frappe.session.user,
             },
             callback(r) {
                 if(r.message) {
                    root_element.querySelector('#imageUser').textContent=r.imageUser;
                 }
             }
});

Is this what you were saying to update?
Thanks!