Setting a default picture in a repeater if the field in database is empty

Hello!

Hoping someone can help with this. I have a repeater connected to a database with people’s profiles and would like to set a default picture / avatar for those users who may not wish to put a profile picture. Therefore I have a field in my database called ‘profilePicture’ and I want to be able to run a query to check if the field is empty for the user and if so, to then display the default image.

I have repeatedly tried to do what is advised in the following threads:

but have not been successful in applying any of these solutions. I’ve gone round in circles between trying to apply a default picture to the page with the repeater, trying to apply hooks after inserting data and attempting to code a query to check if the field is empty but as a beginner at coding but have spent hours not getting anywhere.

Wonder if someone would be so kind as to help me with this.

if ( priceFiled === undefined) {let price = ‘$0’}

Thanks for the coding Carlos but I’m afraid it’s a bit too minimal to help me with my skill level of coding, I suspect you have provided me with a code that is querying if something is empty but why does part of the coding contain price? A bit of an explanation would be appreciated as I am struggling to query whether a field in database in empty and if so I would like to then insert the default image.

Alternatively I’ve also tried to do the following as suggested in a different thread:

let img = $w("#image").src;
console.log(img);

$w("#image").src = "wix:image://v1/baadf00dc00010ffd15ea5efee1dead3bfa8a_4d48e83a93f34e369fa7~mv1.jpg/_.jpg#originWidth=360&originHeight=240";

replacing the “wix:image://…” code with my own image’s url but this hasn’t worked. Not sure if it’s because I want it to show in a repeater if that makes any difference? Or perhaps I’m missing a whole lot of coding that supposed to go with this.

A point in the right direction would be much appreciated.

Hi,
Did you ever find an answer to your query?? I have the same problem…

I have the opposite issue - empty ones that are left empty on purpose show a default image for some reason. I have other repeaters where an empty image field doesn’t display anything - which is what I wanted. Why is this happening?