• Resolved elphnt

    (@elphnt)


    First off, I know this question has probably already been asked and I’ve done plenty of Googling about it too, but can’t really seem to find a conclusive answer… that is, how to successfully replace images on WordPress.

    Example: I’ve uploaded an image called Image.jpg but I’ve made a tweak to the source image and want to upload a new copy with the same name (Image.jpg). The image is only used in one place so I don’t need to replace all instances of it. I could quite easily delete the original image, upload the new one and get on with it, but it just doesn’t work!

    First off, why does this just not work? If I delete the 1st file and re-upload a new one, it seems strange that there isn’t some mechanism built into WordPress to say, “Hey, this is clearly a fresh upload, let’s display the new version”. And if I’ve supposedly deleted the old version, how does WordPress even manage to display the supposedly deleted older version? I’d love to understand why this works (or doesn’t work) the way it does so I can better learn how to deal with it.

    Secondly, what is the best way to achieve the result from the example above; successfully uploading a new version of an image and having it display the new version and not always display the old version!

    I’ve tried the Enable Media Replace plugin and even then it still doesn’t always work for me. The only sure-fire way I’ve found to get WordPress to see the upload as a new image is to give it a different name, but that’s a little tedious and there are really only so many variations one can make, and from an organisational POV it’s just really annoying to have things called Image_1.jpg

    Any help with this is greatly appreciated! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Part of the reasoning for uploads to need unique names is that WP handles multiple authors all editing at the same time. You probably wouldn’t like it if your image.jpg was overwritten by another author who just happened to choose the same name for a different image.

    The Enable Media Replace plugin is the way to go, and although you might think it didn’t work, it did.
    What you might be seeing is the cached image. Your browser doesn’t know that the image changed, so it simply shows you the one it already has, instead of downloading it again. You might think that deleting your browser cache would fix the problem, and it would… but only for you. Any visitors that had been there before would still see the old image, since they don’t know to delete their browser cache.

    There are ways to tell the browser to download instead of use the cache. It’s called expiry headers. There are plugins that help you manage those, but mostly you don’t need to worry about it, unless you have a lot of repeat visitors and some important change. Themes and plugins use WP’s built-in version parameter for their CSS and script files, so that the changed file is loaded instead of the cached version. But this isn’t done on media files.

    You didn’t mention if you are using a caching plugin, but this can also complicate things when you want to replace an image.

    Thread Starter elphnt

    (@elphnt)

    Hi Joy,

    Thanks for the reply – that totally makes sense about the multiple author thing. It’s just me running my site so that definitely didn’t occur as a potential issue.

    I am using a caching plugin, but I always clear the cache after making changes, but I totally forgot about my own browser’s cache! It certainly is an awful lot of effort just to get an image to show up >_<

    The expires headers thing is not something I was aware of (or that there are plugins to control that) so I’ll do some research into it!

    Thanks so much for the reply – always glad to learn new things about how WordPress works! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Replacing Images Correctly’ is closed to new replies.