Question:
Last time I checked, adding a default image inside the “default” of the CMS field, doesn’t work when a new item is created via code.
Therefore I’m trying to add a “default” image when a new item is added with code.
How do I do that?
.
.
What have I tried:
I tried getting the location of a specific image, from my Wix Gallery, by adding the image somewhere on my site and then running this code:
let img = $w("#image1").src;
console.log(img);
The console logged something like this:
wix:image://v1/ca7060_d1c9a63b2c146b9da674fa5e35869~mv2.jpg/_.jpg#originWidth=2989&originHeight=2000
So I imagine that that is the location of the image, to try and pull from.
But when I add it to my “create new Item code” …it says:
Cannot find name 'wix'
If I remove that it says:
Cannot find name image.
My code looks like this:
const myCollection = "Projects";
const saveNewProject = () => {
let toInsert = {
"title": $w("#projectTitle").value,
"profileImage": wix:image://v1/ca7060_d1c9a63b2c1446b9ada674fa5e357869~mv2.jpg/_.jpg#originWidth=2989&originHeight=2000
};
wixData.insert(myCollection, toInsert)
.
Conclusion:
Anybody able to help?
A big thanks in advance.
X