I used Adminer to safely and efficiently replace featured image extensions with .webp in the database, avoiding manual updates while preserving file paths and post associations.
Using Adminer to Bulk Update Featured Image Extensions for WebP Optimization
When optimizing my WordPress site for performance, one of the biggest wins came from converting all images to the modern WebP format. But unlike resizing or compressing images, changing their file extensions across 60+ posts manually would have been tedious—and error-prone.
That’s where Adminer came in.
Adminer is a lightweight, single-file database management tool that gives you direct access to your WordPress database without bloated interfaces like phpMyAdmin. I already had it installed on my server behind a password-protected page and a randomized filename (dbtool_xk9s8f3.php
) for security—so I could safely run SQL queries whenever needed.
The Challenge
I had dozens of posts and custom post types (“chapters”) using featured images with .jpg
or .png
extensions. I wanted to replace those with .webp
versions—but keep the same filenames so WordPress wouldn’t lose track of them.
That way, when I uploaded image.jpg.webp
, I could update the database to point to image.jpg
, but actually serve image.webp
.
Here’s how I did it:
Step 1: Identify Target Files
Before making any changes, I previewed the files I wanted to update using this query:
SELECT *
FROM wp_postmeta
WHERE meta_key = '_wp_attached_file'
AND meta_value LIKE '%featured%'
AND meta_value NOT LIKE '%.webp';
This gave me a list of all featured images that were not yet converted to WebP.
Step 2: Run the Bulk Update Query
Once I confirmed the selection was correct, I ran the following SQL command:
UPDATE wp_postmeta
SET meta_value = REPLACE(meta_value, SUBSTRING_INDEX(meta_value, '.', -1), 'webp')
WHERE meta_key = '_wp_attached_file'
AND meta_value LIKE '%featured%'
AND meta_value NOT LIKE '%.webp';
This query:
- Finds the current extension of each file (e.g.,
.jpg
,.png
) - Replaces it with
.webp
- Only affects rows associated with featured images
- Skips any files already updated to
.webp
After running this, WordPress started pulling .webp
files—even though the original path said .jpg
. As long as the .webp
file was in the correct uploads folder, everything worked seamlessly.
Step 3: Upload the Converted WebP Images
I used local tools like ffmpeg
and image converters to batch convert all my .jpg
and .png
images to .webp
, keeping the same base filename. Then I uploaded them to the corresponding directory on my server.
No need to reassign featured images or touch the WordPress editor—everything auto-linked because the filenames matched.
Step 4: Optional — Rename Files First (Now My Preferred Method)
Over time, I realized there wasn’t much time saved by trying to preserve old filenames. Now, I usually rename files to end in .webp
before conversion and upload. This avoids confusion and potential issues if another post references the same image under its original name.
Still, being able to bulk-replace extensions directly in the database via Adminer was a powerful trick that saved me hours during early optimization phases.
Final Thoughts
Adminer proved invaluable—not just for this task, but for many others like debugging theme data, managing custom fields, or cleaning up orphaned entries.
By combining SQL queries with smart file management, I was able to switch out image formats at scale—without plugins or manual edits. It’s a great example of how a little technical control over your WordPress database can lead to big efficiency gains.