How to show image in Items list view?

I want to show image in Items list view as it shows in the above image instead of url, without using image view option as shown below

1 Like

Hi @a7medalyousofi

In your doctype, you need to set the “image” field

Hope this helps.

Already sets

Still show image url in listview

1 Like

@a7medalyousofi

Ok, I missunderstood your requirement.
Use formatters for customize listview …

frappe.listview_settings['Item'] = {
    formatters: {
        image(value) {
            if (value) {
                return `<img src="${value}" style="height: 40px; width: auto; border-radius: 4px;" />`;
            }
            return '';
        }
    }
};

Hope this helps.

9 Likes

Thanks, it works

Is there a utils function that is used to return small size of image, instead of a full image ?

Can you insert an image to show where to put these code? I tried but failure. Thanks

@focuser2009
You need to create new Client Script

Yes, I made it, but still not display in list view, see below:

Where is the mistakes?

Thanks in advance.

Go to Menu in Item List –> Click on List Settings

Click Add


Check Image and Save

image

you are applying this code on form which is wrong.

Select List in Apply To,
then this code will work


Yes, he has to select List

Ok, I got it. thanks so much.

I got it now, thanks so much :grinning_face:

1 Like