Anyone know how to change a string in a post programatically?
Hi. I embed certain images from government weather websites on an hourly basis. I keep the same filename (like map1.png). I put each one into a space post using an \ and they display perfectly. But I have a pesky problem - user browsers cache the image on initial visit of a post and then always are stuck seeing the same image in future. Again, I create the post once and let my behind the scenes chron job update the image every hour. I should never need to change anything in the post.
Normally I would add a cache Buster, tracking on a ?v=12345 some random string. That way the browser sees the img as new each time.
I tried a variation on the \ like this:
<img src="javascript:document.write('https://www.mydomain.com/wp-content/uploads/mapfetch/radar_weather_gov_ridge_standard_SOUTHEAST_loop.gif?v=' + Date.now());" alt="Southeast US Regional Radar Loop" width="800">
But the JS date.now does not execute. Note sure why, but must be something to do with the way posts are created. I already realized that shortcodes don't work if added to a post.
Looking for the smartest way to fix this. One thought is to use a filter of some sort to change the posts as they are dynamically displayed, changing a known fixed string (say the 12345 in the example above) to a true random number. I could just preset the 12345 for each image that needed to be busted.
Anyone happen to know what would work? I want to try to keep inside the fluent guardrails and not immediately hackathon my way to a solution.
Thanks for any advice :)
PS I am using a space to store these weather maps and so on, as it keep permissions and access all perfect inside my community. Like a library for the users of different levels.
