• Resolved Masidus

    (@masidus)


    Hello,

    We are having an issue with the media library. Say we have image xyz.jpg uploaded, and then we delete the image and upload a different image also named xyz.jpg, then the image doesn’t update in the media library, on the front end, or anywhere for that matter.

    After hours of research, we’ve come to this understanding:

    “This issue occurs because WordPress doesn’t actually delete the physical file from the server when you delete an image from the media library. Instead, it just removes the reference to the file from the media library database.

    When you upload a new file with the same name as the previously deleted file, WordPress detects that a file with that name already exists on the server and uses the existing file instead of creating a new one.”

    We have looked through multiple other support tickets which point to the same issue and we have tried various fixes to try and rectify the issue – replacing the source image via FTP does not change the issue, it is not a caching issue as we have disabled all caching, we are using CloudFlare and have fully purged it’s cache also with no luck, we have tried varying Image Replacement plugins which seem to replace the image as the file size change reflects this, however the image still does not update on both the backend and the front end…

    Ideally we need a function to be able to replace the image as this will preserve all links to the image, however we can’t get it to change at all at the moment.

    Any help would be thoroughly appreciated, many thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • In the cases that I’ve seen this happen it’s been because my browser has cached the old file. That caching is not controlled by the website, Cloudflare or anything else, just my browser keeping a copy of those files locally.. I just have to do a hard-refresh and I will see the new version of the time.

    As a note, this happens only when the files have the same file name. If you upload a file with a new name this won’t happen.

    If you think that’s not the case, can you give us an example? Show us an image on your site and use an image hosting service (lots are available free) to show what the image should be. That way we can see for ourselves if that’s happening.

    Thread Starter Masidus

    (@masidus)

    Hi @catacaustic

    Thank you for your detailed response.

    Clearing the browser cache by doing an ‘Empty cache and hard reload’ solved some of the issues where the images had been directly replaced using the ‘Enable Media Replace’ plugin, however images which had been deleted from the media library only were appending a number onto the image filename and uploading this image as a separate file.

    This was causing the original image (EG image.jpg) to not be replaced and for ‘image-1.jpg’ to be generated instead.

    The remedy for this we found here under ‘Using SSH/FTP & Database’ – https://www.h3xed.com/web-development/how-to-bulk-delete-all-images-in-wordpress-media-library-and-database

    By deleting the three database entries for the original image and each of the variations and then removing all of these images via FTP also, we were able to get the filename back to ‘image.jpg’ with the newly updated image.

    It would be a huge timesaver if an image replacement function were built into WordPress, which would alter not only the database tables but the actual image file in /wp-content/uploads

    Also the ability to remove both the database entries and the FTP file upon deleting from the media library would also be of incredible use as manually having to run this operation for hundreds of images would be very intensive.

    Hope you’re keeping well and thank you for your time!

    Thread Starter Masidus

    (@masidus)

    Hi @catacaustic

    Upon further investigation we are still having the same issue – emptying browser cache and hard reload does nothing, deleting all images via FTP doesn’t help, removing all relevant database entries doesn’t work either, combining all of these is still producing the same result of the image not updating.

    EDIT – you definitely need to clear CloudFlare CDN as a part of this

    Steps to fix –
    – Delete image in media library
    – Check three database entries are gone
    – Check FTP files are all gone
    – Clear CDN
    – Go into developer console on browser and force an ‘Empty cache and hard reload’ by right clicking on the refresh button

    If there are any further protocols which can be put in place on WordPress to prevent this being an issue that would be of incredible use – many thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Media Library – Images not updating’ is closed to new replies.