Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

Optimising image filenames in bulk without causing 404

How can I change all my filenames in bulk without causing 404

         

sfc500

9:33 am on Sep 7, 2015 (gmt 0)

10+ Year Member



I've had a Wordpress blog for a few years, and never really bothered optimising ALL the image file names. I'm now wanting to go through and tighten things up, but it looks like the most effcient way to quickly optimise all the filenames, is to download via FileZilla, rename then upload.

However, this is going to 404 tons of my images in blog posts and I'd have to go through manually and ensure the links are correct. Unless, I put 301 redirects to the new images - but I figure this would slow the load time down and be more hassle than it's worth!

What would be the best way to optimise all these images?

Thanks!

not2easy

1:43 pm on Sep 7, 2015 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Welcome to the forums sfc500! The best way to optimize images is before they are added to a website. Once you have pages with image media links in WP, you should not either remove the images or rename them unless the page/post is being removed or unless you manually change the image files.

Changing the name of an image loads a broken image icon (from your browser) to the page as it is viewed, it does not produce a 404 error for the page (except in your server logs). 301 rewrites for each image - with tons of images - is not beneficial for performance.

WordPress is a rich and diverse platform that many developers collaborate on to improve via plugins that offer specialized functions. A plugin to do the job may exist and if so you can find it at wordpress.org in their plugins directory.

tangor

10:42 pm on Sep 7, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Step one. Change your image naming practices right now.
Step two. If you think it necessary, then change the images names one post at a time as you have time, energy, or perceive a true need for such change.

I think in the long run you'll do Step one and ignore Step two.

As for something that will change the names, then do a bulk rename of all links in files, it is possible, barely, to retain the original names in a separate file. Use that file to find/replace (via another script/batch operation, probably an auto renumbering style) and save that output. Then use that output file to feed, again via script, an editor that will accept command line instruction to search all files for that "string" replace it, complete to NEXT then continue through the rest of the input file until all web files have been updated with the new filenames. Best you do this on a copy of the website that is NOT web facing. When complete, over write the website with the updated files and renamed files (deleting anything that you don't need).

It can be done. It is a pain in the a$$ets of time and money, but doable. Question is, do you really need to correct all that has gone before, or just start doing it the way you want RIGHT NOW?

Depending on your site, most time older stuff will be deleted or archived off the active site and that will eventually clear up your backlog.

Good luck!

sfc500

8:56 am on Sep 8, 2015 (gmt 0)

10+ Year Member



Hey!

Thanks for your response!

Yeh, it's looking like it's going to be a lot of time and effort. I'd say about 70% of it is optimised but it came down to laziness recently and lack of time that I just got images up without optimising them. I'm starting to think it's not worth the hassle based on just being filepaths! Maybe I'll just wait until I re-do the whole site and update the images then, rather than looking for a short term way of optimising images.

Great to know this for clients as well, as I know some of them have hundreds of products!

Thanks again