in essence, the 404 errors are occurring because WordPress is a visual CMS that converts your content into code so that it can be presented in a format suitable for web design.
When you create a post and add an image by clicking “add media” and then selecting the image/resizing/repositioning etc. WordPress is working in the background to produce the code behind all of your choices (you can see this code by going to “text” in the editor).
This code adds an image in text format. So when you select the image you want (let’s call it “my image.jpg”) for your post and click “insert” WordPress compiles a code similar to:
<img src="https://yourdomainname.com/wp-content/uploads/2019/08/my-image.jpg" />
When you change the file name of this image (let’s say to “my new image.jpg) then when your post loads, the code is still trying to load the above code with the old image name.
You don’t need to complete 404 redirects for all images, but you do need to update the images in your posts to make sure the code is calling for the new image (<img src="https://yourdomainname.com/wp-content/uploads/2019/08/my-new-image.jpg" />).
To do this, you will need to click on the image within the post editor a reselect the same image (with the new name) and insert this into your post, then click to update the post.
This can be very tedious, depending on how many images/posts you have, but you will keep getting errors until this happens
If you change an image’s filename by editing through the modal accessed from post edit screens, the one insertion in the current post will be updated accordingly, but any other URLs elsewhere on the site will not be updated. If you edit directly from the media library without going through post edit screen, no URLs are updated anywhere in post content.
You could setup redirects, but unless there is a stringent re-naming framework, you will end up with a LOT of redirects for the server to process. Not good. You can use the Better Search and Replace plugin to seek out all occurrences of a specific name anywhere in the DB and update them to the new name. You still need to do so for every name, unless there is that stringent re-naming framework, in which case regular expressions can be used to do structured renaming.
Actually, I think you need to get the pro version to get RegExp support. However, you can get the underlying tool from interconnect/it for free, which includes RegExp support. It is however a standalone tool, there is no plugin. The code is installed directly on your server. The code is just PHP files, you install by just uploading the files. It’s not like you need to use apt-get or anything.
Hmmm thanks team..I think i am following…dont yet speak the tech jargon though…
so what i am understanding.. is that like when you change the name of a post after it has been published you have to either update the permalink to the new name or make a redirect… changing the name of and image from eg: 000012img.jpg to for example: writing the post1.jpg to reflect the post name.. you also need to update the permalink for the image.. so the code can find the new photo..
so would i be correct in saying…. not yet understanding the jargon.. and easy way to update the image locations would be either to a) edit the image permalink or b) just delete the image, and re load it in the same place with the new name.. bit laborious..yes but effective?