Hi guys,
I want to fetch all data of my database using WiX http request. This works fine.
In addition I want get the URL of each image, which is stored in the database to process it later.
For images which I uploaded myself by using the media manager it works again fine.
Example URL:
https://static.wixstatic.com/media/1d3270_a5700c18d5ee43568420b761f4c6d427~mv2_d_3000_2000_s_2.jpg/v1/fill/w_3000,h_2000/irina-grotkjaer-x-Ae7SJKgr0-unsplash_edited.jpg
The problem occurs, when I try to extract the URL of an image, which has been uploaded by a member of the site. Everything I can extract from the database is always something like this:
image://v1/33c34e_e281899cdd2943d3bacd7fa88a487418~mv2_d_2890_1780_s_2.jpg/2890_1780/33c34e_e281899cdd2943d3bacd7fa88a487418~mv2_d_2890_1780_s_2.jpg
I searched this forum for an issue like that and found one. I’ve implemented the code, but it the “let regexp = /.+?(?=.png)/;” returns null. I tried the code without this expression, but the produced link is wrong:
https://static.wixstatic.com/media/33c34e_e281899cdd2943d3bacd7fa88a487418~mv2_d_2890_1780_s_2.jpg2890_1780/33c34e_e281899cdd2943d3bacd7fa88a487418~mv2_d_2890_1780_s_2.jpg.png
export function getImageUrl(imageSRC)
{
if (imageSRC.startsWith("wix:image://") || imageSRC.startsWith("image://")){
console.log(imageSRC);
let regexp = /.+?(?=.png)/;
var newimagesrc = regexp.exec(imageSRC)[0];
newimagesrc = newimagesrc.replace('wix:image://v1/', '');
newimagesrc = newimagesrc.replace('image://v1/', '');
newimagesrc = newimagesrc.replace('/', '');
let wixImageURL = "https://static.wixstatic.com/media/";
return wixImageURL + newimagesrc + ".png";
}
return imageSRC;
}
Thanks for your help in advance!