Default image if the collection's cell is empty. Is it possible?

I’m building an intranet system, where I have a form that allows to register new users, including uploading avatar photos, but when I create a new user and don’t upload any image, if I open the profile that I just created, the image that is linked to the Users collection gets all white, because the profilePhoto’s cell that belongs to the user is empty.

Is there a way to set a default image, so, if I don’t upload any photo, it loads a default image?

Thank you!

You can surely solve this by using some CODE.

  1. Quering your DB-Values

  2. creating a → if-else-query

Pseudo-CODE…something like this…

if(value of db-field is empty) {show my predifined PIC}
else {show the current DB-Field-PIC}

Thanks for your answer, Russian.

I tried something like this, but it didn’t work.

.then( (results) => {
 if(results.items.length > 0) {
        $w("#text").text = "THERE IS A PHOTO"
    } else {
        $w("#text").text = "THERE IS NOT A PHOTO"

Got any idea?

This line here is SURELY WRONG!


You put a DATASET-NAME/ID, but a COLLECTION-NAME is expected!


Run the following CODE…

import wixData from 'wix-data';


function myFUNCTION(){
   //.count() // <<<------- NOT sure if this can be used here!!!!
   .find()  // <<<------- Instead using this one.
   .then( (results) => {console.log(results)
      if(results.items.length > 0) {console.log("Existing items found")
         $w("#text").text = "THERE IS A PHOTO"
      else {$w("#text").text = "THERE IS NOT A PHOTO"}

Open your CONSOLE and take a look onto all the given RESULTS and informations!