• Resolved rabbitskmc

    (@rabbitskmc)


    Hi, after regnerating images, many of the file names / paths were changed from uploads/month/filename.jpg to uploads/month/filename-1080×810.jpg for example. So now, even though I can see the image in the media library, and it shows the original path, it doesn’t show in the WP editor or the live site because this is now showing the new URL. Why has it done this and how do I fix without having to manually remove the dimensions from the end of the filename (which works by the way – when I remove the numbers, the image comes back to life). Many thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support bindlegirl (a11n)

    (@bindlegirl)

    Hi @rabbitskmc !

    The Regenerate Thumbnails plugin checks all the registered image sizes on your site and then recreates them. All images in WordPress that are not full-size images get the new file name such as filename-1080×810.jpg.

    What problem were you trying to solve by using Regenerate Thumbnails? It sounds like you never wanted to create thumbnails (or other image sizes). Please note, WordPress creates different image sizes by default, so you should have seen some of them on your server.

    …it doesn’t show in the WP editor or the live site because this is now showing the new URL.

    I’m not sure I understand what you see here. If the images got a new URL using a file name such as filename-1080×810.jpg and that file exists on the server, the image should be displayed. The original file should also still exist on the server. Can you share some screenshots of what you see?

    There is a checkbox on the Regenerate Thumbnails page that enables the plugin to delete old images. It comes with a warning: Delete thumbnail files for old unregistered sizes in order to free up server space. This may result in broken images in your posts and pages.

    Did you use this option?

    Thread Starter rabbitskmc

    (@rabbitskmc)

    HI thanks so much for taking the time to reply. TBH, I can’t remember what has gone on but it all looks a bit of a mess.

    I know this.

    I changed the registered image sizes in the functions file to try and reduce the number created and also because my themes sizes had changed. It went from 680×450, 340×225, 680×900, x340x540, 320×321, to 180×180, 720 and maybe one more?

    I then regenerated thumbs.
    Not sure how I add screen shots.

    Thread Starter rabbitskmc

    (@rabbitskmc)

    So for eg upload/2020/01/originalimage.jpg is the name of the image in the media library and on the server. In the post itself, in the editor, the image URL is now originalimage-680×510.jpg so it can’t find the image in the media library. If I edit the 680×510 off the end of the url, the image comes back because it’s now reading the correct path. I don’t know how this happened and I was trying to get a bulk fix so I didn’t have to go into all my posts to edit all images.

    Plugin Support bindlegirl (a11n)

    (@bindlegirl)

    Thanks for the clarifications @rabbitskmc !

    I’m a bit confused about the file originalimage-680×510.jpg since you don’t mention that size as either an old one or the new one.

    It sounds like you removed the registered sizes and the regenerated thumbnails with the delete old images option checked. Since these image sizes were no longer registered, the files got deleted and you have broken URLs in your posts.

    There are several ways you can try fixing this:

    1. Edit all posts manually or using a database tool. Tools for bulk editing database entries can be dangerous if you are not sure what are you doing and may not work in all cases.
    2. Register missing sizes again and re-run regenerate thumbnails. The missing sizes should get recreated and URLs won’t be broken. You can end up with a lot of files on your server by doing this. Also, you need to know which sizes need to be re-registered.
    3. Try using Jetpack and its Site Accelerator feature. Jetpack creates required sizes on the fly and saves them on WordPress.com CDN (for free). The upside is that this can be a fast fix and it can reduce the number of files on your server. The downside is that removing a file from WordPress.com CDN can be difficult, ie. you need to know exact file names (with sizes) that you want to remove.

    You can check out the documentation here: https://jetpack.com/support/site-accelerator/

    Please note that I don’t know if any of these options would be wrong for your site since I don’t know how it was built and the site setup. In any case, I recommend you create a backup of your site before making any changes.

    As for the screenshots, you can add them to a public document (Google doc for example) or use a tool such as https://app.prntscr.com

    Hope this helps!

    did you ever find a fix for this @rabbitskmc?

    The same exact thing happened to me. I’m meticulous about my file sizes. I want WordPress to display MY file sizes in galleries and single images in my posts. I tried to fix this by removing multiple thumbnail sizes and then regenerating thumbnails.

    Regenerate thumbnails did a wonderful job at removing all the file sizes I don’t need from my server. Now I need to finish the other half. Rewrite the img code on my site. Fix broken image links to be specific.

    In my single posts, WordPress is still spitting out code like
    <img src=”https://mysite/wp-content/uploads/my-image-816×1024.jpg&#8221;
    of course, that file’s not there anymore. I don’t want it there. I want to change the html to this: <img src=”https://mysite/wp-content/uploads/my-image.jpg&#8221;

    NOTE: image dimensions are only showing for about half of the images in my posts. I’m not sure why.

    I tried a filter to remove thumbnail dimensions from the_content. but it didn’t work.

    Does anyone know how to remove image dimensions in bulk so @rabbitskmc and I don’t have to edit hundreds of posts?

    I found a fix programmatically. It will not fix images in the editor, images are still broken in mine. But if you have dozens of broken images and need them back NOW…
    add this to your themes functions.php or with a code snippets plugin that does php:

    function replace_content($content) {
    		$content = preg_replace('/-([^-]*(\d+)x(\d+)\.((?:png|jpeg|jpg|gif|bmp)))"/', '.${4}"', $content);
    		return $content;
    		}
    		add_filter('the_content','replace_content');
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘URLs changed after regenerating’ is closed to new replies.