Skip to content
Advertisement

Include image on wordpress site and update site when image gets overwritten

I’m designing a WordPress Site right now, and want to include a webcam to give users the possibility to see the live weather. Therefore a picture from the webcam is uploaded to the wordpress webspace under wordpress/wp-content/uploads/webcam/upload.jpg every 5 minutes.

I now want to include this picture (which changes every 5 minutes but always has the same name) on my website.

Currently I’m using simple html to include the picture:

<img class="alignnone size-medium" src="https://XXXXXXX.de/wp-content/uploads/webcam/upload.jpg" width="1280" height="720" />

I can see a picture on the website, but when the image on the server gets overwritten, the website still shows the “original” picture.

How can I achieve a that a user who logs onto the site always sees the newest version of the picture on the server? As I said, the name of the file is always the same.

I’m using the impreza theme if this is important.

Thanks!

Advertisement

Answer

Try to use a get param to make browser understand it is a new URL and it will fetch. e.g use src attribute something like
src=”https://XXXXXXX.de/wp-content/uploads/webcam/upload.jpg?your_Ver_var=currenttimeoutput()”
Implement currenttimeoutput() or use inbuilt php time method to render it

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement