Hi, I really need help to get an image URL using code on a webpage.
I have read the image API reference but it does not discuss my case.
This is the issue:
After filling up the form (name, etc), my patients are required to upload their "skin problem" image so that they can get an effective consultation.
1. A default image, an upload button, and a submit button are provided to the patient.
2. When the patient attaches their image on the upload button, their image is uploaded to my gallery (not database) and the default image changes to the image that the patient uploaded as a preview (this is an OnChange event of the upload button). If the user clicks and attaches a different image on the upload button again and again, the same event will continously reoccur.
//this is the code
export function uploadButton_change(event) {
if ($w("#uploadButton").value.length > 0) { // patient chose an image
$w('#loadingGif').show()
.then(() => {
console.log(`Uploading '${$w("#uploadButton").value[0].name}'`);
$w("#uploadButton").startUpload()
.then( (result) => {
$w('#submitButton).expand()
let imageUrl = result.url
//this "imageUrl" does not contain "static.wixstatic.com/media"; hence, when searched on browsers this image cannot be found. It starts with "image:" instead of "https://"
setTimeout(function() {
$w('#loadingGif').hide()
$w('#image').src = imageUrl
//After the "setTimeout" function is done, the default image on the webpage is then changed to the image that the patient uploaded (as a preview)
// the image on the webpage contains the "static.wixstatic.com/media". Because when I click right on it, I can copy the image address and search it on browsers. This is the image URL that I want to get.
$w('#uploadButton').buttonLabel = "Change image"
$w('#instruction').text = "Your image has been uploaded successfully. You may change the image as you wish or click submit to send your consultation form"
}, 1000);
})
})
}
So my question is, how do i get the image URL which contains "static.wixstatic.com/media"?
Thanks in advance! really appreciate it if you can help me!
Thank you so much J.D.! This means so much to me
let imageUrl = "https://static.wixstatic.com/media/" + result.url.split("/")[3];