I have a single image on a dynamic page. How can I get source?
At first I tried something like this:
let source = $w("#imageName").src;
But that didn’t work — all I got was the source for the image in the editor, not the image on the live dynamic page.
So then I tried something like this (and variations of this ‘getCurrentItem’ code):
var currentItem = $w('#dynamicDataset').getCurrentItem();
currentPic = currentItem.imageFieldKey
let source = currentPic.src
But that didn’t work either. What am I doing wrong?
Please and Thank You
: )
Do you do it after the dataset is done loading? Inside datasets onReady?
This line
currentPic = currentItem.imageFieldKey
should give you the source, there is no src property on image fields, just on image elements.
Then I guess my code after that line is wrong … all I wanted to do was split the src url. I will try again in the morning. Thanks.
lol I don’t know. It is barely 7am. I havn’t even dropped off my daughter at school yet.
Yup, it worked. I removed 1 line and that fixed everything. I guess I just needed to take a break from looking at the code to see it with fresh eyes. Thanks.
Being away from code solves a lot of coding issues