SEO image naming: how to rename WordPress files safely

Renaming a published image changes one URL per registered size. What a rename moves, which references get rewritten, which need a 301, and when to leave the name alone.

calendar_today schedule 9 min read update Updated
Christian Ehler Written by Christian Ehler
Grid of matte gray plates in a machined tray running past the frame edges, one slot empty with a single blue lens on its rim

Most media libraries carry two kinds of bad filename. There is IMG_2034.jpg, straight off a camera, and there is final_v3_EXPORT.jpg, straight off somebody’s desktop. SEO image naming is mostly the work of not adding any more of them, and it is nearly free right up until the file is published.

After that it stops being free. Renaming a published image changes a live URL, and WordPress does not keep one file per image — it writes one for every registered size, plus a scaled original on large uploads. Each of those is a URL something may already be requesting.

The answer here is mechanical rather than editorial. By the end you will know what a rename touches on disk, which URLs need a 301 and which never get one. You will also know what no rewrite pass reaches, and when leaving a bad filename alone is the right call.

What SEO image naming actually buys you

Google’s guidance on filenames is one line long. Its image documentation asks for filenames that are short, but descriptive, and its worked example is my-new-black-kitten.jpg over IMG00023.JPG (Google Search Central, checked 2026-08-10).

That is the whole documented claim, and it sits beside three other things the same page names: the alt attribute, the content of the page around the image, and structured data. A filename is one input among four, read in the absence of anything better.

warning
A better filename is not a ranking change

Nothing published by Google says a descriptive filename lifts an image in results, and nobody outside Google can measure one signal’s contribution. A descriptive name gives a crawler something the camera default does not, instead of leaving every other signal to carry the file alone. That is the honest reason to fix names, and it is enough of one.

Naming a file before you upload it

Write the name for the URL it becomes. Lowercase ASCII letters, numbers and hyphens; no capitals, no underscores, no accented characters; the words that describe the subject first and the ones that describe the project not at all.

I score filenames against 40 to 60 characters and 3 to 6 hyphen-separated words. No search engine publishes a limit, so those are a working convention rather than a rule. A name that fits them is almost always descriptive without becoming a sentence.

Drop the filler. Words like with, from, the, and, for, in, on and of read as noise in a slug, and they push the descriptive words out of the first few characters. Prefer chocolate-cake-cream-plate-dessert over chocolate-cake-with-cream-on-a-plate.

For a site publishing in a non-Latin script, transliterate rather than translate — changcheng rather than great-wall for a Chinese-language site writing about 长城. The URL stays legible to the people who search in that language, and stays ASCII for every cache and log that handles it.

info
None of this applies retroactively

Every rule above is free at upload and costs a redirect afterwards. The difficulty with filenames is that the field is decided at the moment you care about it least, and corrected when it is most expensive. Change one habit from this article and make it the one before the upload dialog.

When renaming a published file is worth it

Rename a published image when the current name is not descriptive, not when it is merely unimpressive. Not descriptive means a camera or export default, one name repeated across dozens of files, a language the site does not publish in, or a name that reveals something better kept private — a client, a price, an unreleased product.

Leave the rest alone. A file that is already earning image impressions has a URL with history, and a rename trades that history for a redirect you now have to keep alive. An indexed URL with a mediocre name usually beats a perfect name on a URL that just moved.

Filenames are the cheapest field to get right and the most expensive to change, which puts them in an odd position against alt text, titles and captions. What each of the four is read for is in image SEO beyond filenames.

What a rename actually moves

On disk and in the database a rename is a short sequence. The file moves through the WordPress filesystem layer, the attachment record is repointed at the new path, and the attachment slug is rewritten to the new stem. Then the size variants are regenerated from the renamed file and the old variant files are deleted.

One file becomes one file per registered size, and the number of registered sizes is whatever the theme and its plugins asked for.

Two consequences fall out of that and neither is obvious. The regenerated variants are new files, so a thumbnail somebody hand-cropped comes back as an automatic crop. And because the attachment slug moves, the attachment page URL moves with it — that one is not an image URL, so an image redirect never covers it.

What a rename moves, and what it leaves alone
Item What the rename does What is left to you
The full-size file Moved on disk, attachment record repointed Nothing
Registered size variants Regenerated from the renamed file, old files deleted A hand-cropped variant returns auto-cropped
The scaled original Renamed with everything else Nothing
The attachment slug Rewritten, so the attachment page URL changes No image redirect covers that URL
Alt text, title and caption Untouched — stored on the attachment, not in the name Written and reviewed separately
The image itself The full-size file is moved, not re-encoded Nothing gets smaller. A rename is not compression

Every URL a rename has to account for

The URL set is larger than the file set. A correct map covers four kinds of URL: the canonical attachment URL, the upload-relative form of the same file, one URL per registered size, and the scaled original on a large upload.

The count varies by site: registered sizes come from core, from the theme, and from any plugin that adds one, so the same rename produces a different number of rows on two sites. That is the reason not to write a redirect list by hand from memory.

Each old URL needs its own row and its own target. A thumbnail that redirects to the full-size original is a working link and a bad one.

Then the redirects: one 301 per old URL, each pointing at the variant that replaced it. Sending every old size to the full-size file is the shortcut that reappears later as a 2 MB image in a thumbnail slot. The map, the rewrite pass and the redirect row are documented in how renaming and 301 redirects work.

How the redirect gets served, and when it does not

A redirect row does its job only when something reads it. In WordPress that happens on template_redirect, so the request has to reach PHP before any lookup occurs. This is the boundary most people never check, and the web server decides it rather than the plugin.

An Apache install using the standard WordPress rewrite rules hands a request for a missing file to index.php, so WordPress runs and the redirect fires. Several common Nginx configurations serve the uploads directory directly and answer a missing file with their own 404, and PHP is never invoked. Request one old thumbnail URL with curl before you trust the mechanism across a batch.

In Image SEO Optimizer the rows live in a table named for the site prefix plus infyp_redirects, the lookup runs only for request paths under the uploads directory, and the response is a 301 with a one-week Cache-Control header. Capture is on by default and can be switched off — with it off the rename still happens and the old URLs 404.

Rows carry an expiry, and the default is 12 months. The other choices are 6 months, 24 months and never, and a daily job marks anything past its date as expired so it stops serving. An expiry delays the failure rather than removing it: the 404 arrives a year later, on a URL nobody is watching. If the images are linked from anywhere outside your control, set it to never.

Rename the same image twice and the first row has to be rewritten to point at the final URL, or you have built a redirect chain by hand. Which rows exist, how often each was hit and when, are listed in the 301 redirects manager. A row still showing zero hits a month later tells you the old URL had nothing pointing at it.

The references a rewrite reaches, and the ones it does not

A 301 keeps old URLs working. It does not clean your content, and a page full of redirected image URLs pays an extra round trip per image. The rewrite pass is what stops that, and it is the half people forget.

The pass replaces the filename stem rather than the whole URL, which is how every size variant gets caught in one operation. It also has to handle the encoded forms of that string: percent-encoded in some markup, slash-escaped inside page-builder JSON.

Six builders are covered by adapters — Gutenberg always, then Elementor, Visual Composer, WPBakery, Uncode and Divi when each is active. Elementor keeps its layout as JSON in post meta, so that adapter decodes the data, replaces inside it and re-encodes it, rather than swapping strings across serialized text.

Theme code, a CDN cache and someone else’s page are the references no rewrite pass reaches. That is the job the 301 exists for.

Three kinds of reference stay out of reach: URLs hard-coded in theme PHP, anything held by a CDN or a full-page cache, and every reference outside the install — a newsletter sent last year, a partner site, a scraped copy. The first is a grep, the second a purge, the third is what the redirect is for.

info
Renaming and redirecting are often two separate tools

Media File Renamer is the most-installed rename plugin in the directory, at 40,000 active installs (wordpress.org plugin information API, checked 2026-08-01). Its own documentation handles the old URLs by pointing readers at a separate redirect plugin and at a hook for wiring their own (meowapps.com/media-file-renamer/issues/, checked 2026-07-31). Check which half of the job your tool does before running it on a live library: a rename with no redirects produces 404s, and redirects with no rewrite pass leave an extra request on every page.

Doing this by hand, and where it stops

The manual route is real work, not a straw man, and for a handful of images it is the right choice. Rename the file on disk, repoint the attachment record and regenerate the sizes. Then run a dry-run search and replace on the filename stem so the variants come back too, add the redirect rules, and purge the caches in front of the site.

A rename that does not create a support ticket

The order matters more than the tooling. Steps one and four are the two people skip, and they are the two that produce the 404s.

schedule Varies with how many references the image has signal_cellular_alt Advanced
  1. 1

    Count the references before you touch anything

    Search the database for the filename stem rather than the full URL. The stem matches the full-size file, every variant and the scaled original in one query, and the escaped forms inside page-builder data. That number is the one you check again at the end.
  2. 2

    Decide whether the URL has history worth keeping

    Filter the Search Console performance report to the Image search type and look for the file. A URL with impressions is a URL you are trading for a redirect. A URL with none is free to move.
  3. 3

    Run it on a copy of the site first

    Page builders keep image URLs in places a generic search and replace can corrupt, and serialized data is the usual casualty. One rename on staging tells you whether the layout survives.
  4. 4

    Check one 301 per variant, not one for the file

    Request an old thumbnail URL directly and read the status line and the Location header. A 200 means nothing moved, a 404 means the redirect never fired, and a Location pointing at the full-size original means the map was written lazily.
  5. 5

    Purge the CDN and any full-page cache

    A CDN caches a 404 as happily as it caches an image, and the cached copy outlives the fix. Purge after the rename, not before, or the broken state gets cached twice.
  6. 6

    Re-run the reference count

    Anything still matching the old stem is either theme code or a site you do not control. Fix the first by hand and leave the second to the redirect, which is now the only thing keeping it alive.

The arithmetic is where the manual route stops. Finding references, renaming, regenerating, rewriting six kinds of storage, writing a 301 per variant and re-checking takes long enough that nobody does it twice. That gap is what I built Image SEO Optimizer for: it generates the name from the image on your own Anthropic, Google or OpenAI key, renames the file, rewrites what it can reach and writes the redirect rows in one operation.

The limits are worth stating flatly. It renames one image at a time — the bulk runner is Pro. It handles jpg, jpeg, png, webp and gif and refuses everything else, SVG included. It will not overwrite an existing file, and it rejects any name outside letters, numbers, dots, underscores and hyphens. It does not purge your CDN, read your theme’s PHP, or compress anything.

Generated names vary between runs, which makes reviewing a filename before the rename runs a real step rather than a formality. Wiring it into something larger comes down to two filters. infyp_pre_file_rename returns false to cancel a rename outright. infyp_filename_url_map adds URLs — a CDN hostname, a custom size — to the map that the rewrite and the redirect rows are built from.

Frequently asked questions

A 301 is the documented way to say a URL moved permanently, which is why it goes in with the rename rather than after it. It does not make the move free. The new URL has to be crawled and the image refetched, and image results settle slowly. Expect weeks of noise, and read the effect across the library rather than on one file.
Yes, and for a small number of files that is the better answer. Server-level rules run before PHP, so they also catch the requests that never reach WordPress — exactly the case where a plugin-served redirect does nothing. The cost is maintaining them by hand, and one rule per size variant per image adds up fast.
They are regenerated from the renamed file and the old ones are deleted, so the disk does not fill with orphans. The regenerated crops are automatic. A variant cropped by hand in the media editor is gone and has to be redone after the rename.
No. The full-size file is moved, not re-encoded, so its bytes are identical afterwards. The size variants are new files because they are regenerated, but nothing is compressed and no format is converted. Renaming and compression are separate jobs done with separate tools.
Five reasons, all deliberate: the extension is not jpg, jpeg, png, webp or gif; a file with the new name is already in that folder; the name contains something outside letters, numbers, dots, underscores and hyphens; the name runs past 200 characters; or the user cannot upload files. A rename that overwrites an existing file is data loss, so refusing is correct.

One thing to do after reading this: filter your media library to files still carrying a camera or export default, then check how many of them appear in more than one post. That second number decides whether this is an afternoon or a project, and almost nobody has it.

Image SEO Optimizer Pro

The rename half is in the free plugin

Image SEO Optimizer renames the file, regenerates the size variants, rewrites the references it can reach across six page builders and writes one 301 per old URL. One image at a time; the bulk runner is Pro.

Yearly Lifetime Best value

Free

Single-site license – ideal for personal blogs or small corporate websites

$0
Get Free

Personal

Single-site license – ideal for personal blogs or small websites.

$49 /year
  • check_circle 1 Site License
  • check_circle Bulk Processing
  • check_circle Image Context Generation
  • check_circle Real-time Upload Optimization
  • check_circle Best-in-Class AI Models
Get Personal
Most Popular

Freelancer

License for up to 10 sites – ideal for freelancers and developers.

$99 /year
  • check_circle 10 Sites License
  • check_circle Bulk Processing
  • check_circle Image Context Generation
  • check_circle Real-time Upload Optimization
  • check_circle Best-in-Class AI Models
Get Freelancer

Agency

Unlimited Sites – ideal for digital agencies and corporations.

$149 /year
  • check_circle Unlimited Sites
  • check_circle Bulk Processing
  • check_circle Image Context Generation
  • check_circle Real-time Upload Optimization
  • check_circle Best-in-Class AI Models
Get Agency
Share this article
Christian Ehler

I'm a WordPress developer and technical SEO — in search since 2010, currently traveling the world and working from wherever the coffee and wifi hold up. My focus is building WordPress apps on top of AI: automating the daily SEO workflows nobody has time for and preparing sites in depth for how AI-driven search reads the web. InfyPress is the first piece of that.

arrow_back Previous Image SEO: the complete guide for WordPress media libraries Next arrow_forward Alt text SEO: screen readers first, search engines second