Adding default image to collection

I have created a “member directory” for my site following this (excellent) tutorial.

I would like to add a “default value” (an image) for my users avatars. I have tried a couple of things but no joy.

Is there a way to add default values to a collection (in particular, an image)?


You can keep a default image in your site’s media manager and use that as a default image for user avatars.

You will need to do the following:

  • In your site’s dashboard, upload an image to use as your default avatar.

  • Add an image element to a page (even a temp page just for this purpose).

  • Set the image element to image that you just uploaded.

  • In the code pane, add the following lines of code to the pages onReady() function:

let img = $w("#image").src;
  • You will see the image’s url printed in the developer console. It will be a long string that starts with: “wix:image://”.

  • Copy this string, and wherever you want to set the image to the default image, use this url string with code that looks sort of like this:

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

That should do what you need.

Have fun,


1 Like

You TOTALLy Rock!! I had to make a slight tweak but you got me where I needed to be, Huge thank you!!

1 Like

Glad it worked for you. Welcome to WixCode. Have fun!

Hey dmz,

What is the tweak? Is it because on a mistake on my part (I tested first)? Or is it specific to your site?

If it’s useful, maybe you can share?

Your code was perfect! I just changed it to meet my specific site. It actually taught me what I needed which is better than a cut and paste. :slight_smile: I am new to Wix (but not coding) and just needed an example. Thanks again for your help.

1 Like

It didn’t work for me.

I have a repeater containing items that have an image (#gallery4) I want an image to be the default image in case there’s no image attached to it.

Any help ? Thanks !

Where can i find my dashboard…Please help me. I didnt understand where to upload image and paste the code …Please help me …

To upload images, from the editor:

Thank you for quick response. I have uploaded the avatar photo . Where can I paste that code ?

You can add the code to the code pane as I described above.


How can I apply the same with a gallery ? It shows an error on the “.src”

@yisrael-wix Similar vein, but want to have a default image in database field. thoughts?

@jeff-haskins You can add a dataset to the page, connect it to the collection that has your image, then connect the image to the image field in the dataset. You can also set a filter in the dataset to get the image you want.

You could also do a wix-data.query() based on whatever filter conditions you want to get an image. You can randomize the query, or base it on user’s location, the weather, or your current state of mind.

Have fun

Hi, I’ve the image in wix dashpboard, link copied, repeater setup, dataset linked with image but still only getting the results where the images are stored. Other fields are empty.

While filtering there are only two options empty or not empty. I can’t understand how to add default avtar where no image is fetched.

I too would like to update a default image to the gallery field (field type Media Gallery)! Better yet, let us access the Media Gallery via a Media Gallery field type on a repeater or page! I’ve voted for this feature but I’m not sure it goes far enough (when it is implemented).
#multipleMediaFiles #uploadFiles