Hey Guys,
I am stuck in a situation where I need to copy a image in a gallery to a database field with image datatype.
Currently I am using this code to do this:
let t = $w("#gallery").items[0].src.split("wix:")[1];
let tt = t.split("#")[0];
let tttt = tt[0].split("/Image.jpg"); //Removing Title of the image
var table_image_link = tttt[0] + "/192_192" + "/Image.jpg"; //Setting image resolution and adding the tiltle again
let substring = "_.jpg";
if (table_image_link.indexOf(substring) !== -1) {
let ttx = table_image_link.split("_.jpg")[0];
table_image_link = ttx + "/192_192" + "/Image.jpg";
}
$w("#dataset").setFieldValue("tableimage", table_image_link);
This code is working 90 % of time but since I uses string operations to edit the link of the image file, sometimes I get a wrong link and this crashes the table where I am showing the image.
So is there a easy way to copy a gallery image to a field value with image datatype so that I can use it in a database table?