I have an image in a modal and the src comes from a text-input.
When I update the image using another modal which saves the image as the same file name as the first one, it will not update the image in the original modal.
However if I delete the g out of the .jpg in the text input and then retype it will update the image.
Is there a way to get this to do it automatically. ?
I have tried added model update, but this does nothing.
That would be caching, then, as the page is still looking at the same filename. Adding ?var=something should fix that. Just make sure the value after the = changes.
Yep, that worked what I did was on the image upload at the end I added a set value=timestamp (with an output)
On the image input I have included the ?v= which works perfectly.
Thanks for pointing me in the right way @sitestreet
Glad that worked for you. Can you share the code used to put the timestamp there? I wanted to do that so it guaranteed a unique value but the only way I found was using the DateTime component to get the current time but it meant the image was re-downloaded every second!
I’d be keen to know how you got a static timestamp which wasn’t constantly updating.
On the action steps make your last step a set Value unq={{TIMESTAMP}}
On the action for the form for success, add an update Filename+’?v=’+unq
Simple as that. Every time the upload action steps run, then it gives you a new timestamp. As the image only really needs to be updated if it’s changed.
Brilliant. Thanks @gunnery - it was the {{TIMESTAMP}} I wasn’t aware of. Should have guessed it existed, though!
I shall now change my own implementation to use that instead as it’s much more reliable. At the moment I have set a variable to 0 and then add 1 to it every time an image is edited (I’ve given site members the facility to rotate images). But if the page is refreshed then the value goes back to 0 again and the cache does some odd things!
Another reason why Wappler and this community is so great. People can be experts in one area but still need help in others (sounds like I’ve self-proclaimed myself as an expert… sorry, I definitely am NOT!)
Hmm, I’ve just realised your solution is using server actions whereas I want it App Connect. I don’t want to store the value but just use it when displaying the image.
but the image is not refreshing. If I press F5 on the page then the image will refresh.
I have a Server Connect / Server Action which goes off,
finds the image,
rotates it,
saves by overwriting the original file,
On-Success loads the Server Connect / Server Action which is used to display the list
But the file list on the page does not refresh.
LIGHT BULB MOMENT ?!?!
I am not uploading or updating anything into the Database, therefore nothing is changing in the Server Connect / Server Action and therefore nothing has changed to update, so the page will not refresh. Only the image file in the directory has changed.
Hi @gunnery, I know this is 9 months old but it maybe just what I need. My problem sis that I don't know what you mean by item 2. as highlighted here. Can you explain a little more?
I am trying to refresh the image when a 'rotate' button is pressed as per
When this button is pressed the file is rotated in it's Windows explorer folder but is not shown on the browser page. If I press F5 then the image refreshes.
I assume your 'on-success' sets a variable but what is that variable doing?
I couldn't tell what was happening in your second screenshot.
from memory all it was doing was adding something different in the url, If I remember correctly I ended up adding a timestamp on the end of the url, so each time it was different.
Its basically a cache issue.