Hey,
I’m trying to get the image “https://” url from my database for a html Document.
The problem is, that I can’t get the url directly, so I need replace it at first.
I found this function in the forum. It works, but not for my purpose.
export function getFullImageURL(imageSRC) {
let strReturnImage = "";
if (imageSRC.startsWith("wix:image:")) {
let wixImageURL = "";
wixImageURL = "https://static.wixstatic.com/media/";
let wixLocalURL = "";
wixLocalURL = imageSRC.replace('wix:image://v1/', '');
wixLocalURL = wixLocalURL.substr(0, wixLocalURL.lastIndexOf('/'));
strReturnImage = wixImageURL + wixLocalURL;
} else {
strReturnImage = imageSRC;
}
return strReturnImage;
}
Example:
When imageSRC has the value:
let imageSRC = "wix:image://v1/f9b4df_12635b0aaa8f43e6a216ae73648054c9~mv2.png/............";
you get back:
https://static.wixstatic.com/media/f9b4df_12635b0aaa8f43e6a216ae73648054c9~mv2.png
This needs to be done for a hole dataset array.
I have a backend .jsw file, that arrays my dataset.
I changed the code to:
export function button1_click() {
getLocations().then((imageSRC) => { //getLocations() is my backend file
let strReturnImage = "";
console.log(imageSRC);
if (imageSRC.startsWith("wix:image:")) {
let wixImageURL = "";
wixImageURL = "https://static.wixstatic.com/media/";
let wixLocalURL = "";
wixLocalURL = imageSRC.replace('wix:image://v1/', '');
wixLocalURL = wixLocalURL.substr(0, wixLocalURL.lastIndexOf('/'));
strReturnImage = wixImageURL + wixLocalURL;
} else {
strReturnImage = imageSRC;
}
$w("#text23").text = strReturnImage;
return strReturnImage;
});
}
imageSRC is defined as my array. (picture: console.log(imageSRC)
But for some reasy I get this error:
I really don’t know why this error appears.