Blog
Fix Missing Alt Text in WordPress Automatically (Bulk + Auto Method)
Missing image alt text is one of the most common technical SEO issues found in WordPress websites.
Many SEO tools report warnings like:
Images have an alt attribute but are missing alt text
This issue affects:
-
SEO rankings
-
website accessibility
-
image search visibility
-
technical SEO audits
If your site contains hundreds or thousands of images, manually adding alt text is extremely time-consuming.
In this guide, you will learn how to fix missing alt text in WordPress automatically, including a bulk update method that safely fills alt text without changing existing image descriptions.
Why Alt Text Matters for WordPress SEO
Alt text (alternative text) is used to describe images for search engines and screen readers.
Search engines rely on alt text to understand image content and relevance.
Proper alt text helps with:
Image SEO
Search engines can index images more accurately.
Accessibility
Screen readers use alt text to describe images to visually impaired users.
Technical SEO audits
Many tools like Screaming Frog and Ahrefs flag missing alt text as an issue.
Google Image Search
Optimized alt text increases the chances of appearing in image results.
The Common WordPress Alt Text Problem
Many WordPress websites contain images like this:
<img src="wordpress-seo-guide.jpg" alt="">
or sometimes even:
<img src="wordpress-seo-guide.jpg">
This happens when:
-
editors forget to add alt text
-
images are imported automatically
-
plugins insert images without metadata
-
old media libraries contain thousands of images
Manually fixing this for large websites is not practical.
Automatic Solution: Fix Missing Alt Text in WordPress
The method below solves the problem in two ways.
1. Automatic Alt Text Generation
If an image has no alt text, WordPress will automatically use the image title as the alt text.
2. Bulk Update Tool
A custom admin tool allows you to update all existing images in the media library.
3. Safe Updates
The solution never overwrites existing alt text.
It only fills missing alt attributes.
Step 1: Automatically Generate Alt Text for Images
Add the following code to your WordPress child theme or Code Snippets plugin.
/**
* ODesigning - Missing Image Alt Text Helper
* Safe version for Woodmart child theme functions.php
*/
/**
* Generate clean alt text from attachment title
*/
function odesigning_generate_clean_alt_from_title( $attachment_id ) {
$title = get_the_title( $attachment_id );
if ( empty( $title ) ) {
return '';
}
// Remove common image extensions from title if present
$title = preg_replace( '/\.(jpg|jpeg|png|gif|webp|svg|avif)$/i', '', $title );
// Replace separators with spaces
$title = str_replace( array( '-', '_', '.' ), ' ', $title );
// Remove extra spaces
$title = preg_replace( '/\s+/', ' ', $title );
$title = trim( $title );
return $title;
}
/**
* Frontend fallback:
* If image alt is empty, use attachment title as alt
* Does not overwrite saved alt text
*/
function odesigning_set_missing_image_alt_clean( $attr, $attachment, $size ) {
$existing_alt = get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true );
if ( empty( trim( (string) $existing_alt ) ) ) {
$generated_alt = odesigning_generate_clean_alt_from_title( $attachment->ID );
$attr['alt'] = $generated_alt;
}
return $attr;
}
add_filter( 'wp_get_attachment_image_attributes', 'odesigning_set_missing_image_alt_clean', 10, 3 );
/**
* Add submenu page under Media
*/
function odesigning_register_bulk_alt_update_submenu() {
add_media_page(
'Bulk Alt Update',
'Bulk Alt Update',
'manage_options',
'odesigning-bulk-alt-update',
'odesigning_render_bulk_alt_update_page'
);
}
add_action( 'admin_menu', 'odesigning_register_bulk_alt_update_submenu' );
/**
* Count images with missing alt text
*/
function odesigning_count_images_missing_alt() {
global $wpdb;
$count = $wpdb->get_var(
"
SELECT COUNT(p.ID)
FROM {$wpdb->posts} p
LEFT JOIN {$wpdb->postmeta} pm
ON p.ID = pm.post_id
AND pm.meta_key = '_wp_attachment_image_alt'
WHERE p.post_type = 'attachment'
AND p.post_mime_type LIKE 'image/%'
AND p.post_status = 'inherit'
AND (
pm.meta_value IS NULL
OR TRIM(pm.meta_value) = ''
)
"
);
return (int) $count;
}
/**
* Run one batch update only
*/
function odesigning_run_bulk_alt_update_batch( $limit = 100 ) {
global $wpdb;
$limit = absint( $limit );
if ( $limit < 1 ) {
$limit = 100;
}
$image_ids = $wpdb->get_col(
$wpdb->prepare(
"
SELECT p.ID
FROM {$wpdb->posts} p
LEFT JOIN {$wpdb->postmeta} pm
ON p.ID = pm.post_id
AND pm.meta_key = '_wp_attachment_image_alt'
WHERE p.post_type = 'attachment'
AND p.post_mime_type LIKE 'image/%'
AND p.post_status = 'inherit'
AND (
pm.meta_value IS NULL
OR TRIM(pm.meta_value) = ''
)
ORDER BY p.ID ASC
LIMIT %d
",
$limit
)
);
$updated = 0;
$skipped = 0;
if ( ! empty( $image_ids ) ) {
foreach ( $image_ids as $image_id ) {
$existing_alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
if ( ! empty( trim( (string) $existing_alt ) ) ) {
$skipped++;
continue;
}
$new_alt = odesigning_generate_clean_alt_from_title( $image_id );
if ( '' !== $new_alt ) {
update_post_meta( $image_id, '_wp_attachment_image_alt', $new_alt );
$updated++;
} else {
$skipped++;
}
}
}
$remaining = odesigning_count_images_missing_alt();
return array(
'updated' => $updated,
'skipped' => $skipped,
'remaining' => $remaining,
);
}
/**
* Render admin page under Media
*/
function odesigning_render_bulk_alt_update_page() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$result = null;
if (
isset( $_POST['odesigning_run_bulk_alt_update_batch'] ) &&
isset( $_POST['odesigning_bulk_alt_nonce'] ) &&
wp_verify_nonce(
sanitize_text_field( wp_unslash( $_POST['odesigning_bulk_alt_nonce'] ) ),
'odesigning_bulk_alt_action'
)
) {
$result = odesigning_run_bulk_alt_update_batch( 100 );
}
$missing_count = odesigning_count_images_missing_alt();
?>
Bulk Alt Update
This tool fills missing image alt text using the attachment title.
Only images with empty alt text are updated. Existing alt text will not be changed.
Images currently missing alt text:
Batch completed successfully.
Updated:
Skipped:
Remaining:
This automatically generates alt text for any image missing it.
Step 2: Bulk Update Existing Images
For websites with large media libraries, you can run a bulk update.
The bulk update tool will:
-
scan all images
-
detect missing alt text
-
generate alt text from the image title
-
update the media library
Existing alt text remains unchanged.
Example Result
Before
<img src="wordpress-development-guide.jpg" alt="">
After
<img src="wordpress-development-guide.jpg" alt="wordpress development guide">
Benefits of Automatically Fixing Alt Text
Implementing this solution improves several areas of your website.
Better SEO
Search engines understand your images better.
Accessibility compliance
Screen readers can properly describe images.
Faster SEO audits
Technical audit tools will no longer report missing alt text errors.
Image search traffic
Images become more discoverable.
When Manual Alt Text Is Still Recommended
Automated alt text is useful, but important images should still be manually optimized.
Examples include:
-
product images
-
infographics
-
hero banners
-
marketing visuals
Manual descriptions can include context and keywords.
Best Practices for WordPress Image Alt Text
Follow these guidelines for better image optimization.
-
Keep alt text short and descriptive
-
Avoid keyword stuffing
-
Describe the image clearly
-
Use relevant keywords naturally
Example:
Good alt text:
wordpress seo optimization dashboard
Bad alt text:
wordpress wordpress seo wordpress seo plugin best wordpress seo service
Final Thoughts
Fixing missing alt text is one of the easiest ways to improve WordPress SEO and accessibility.
By implementing an automatic alt text solution, you can:
-
bulk fix missing alt attributes
-
improve technical SEO
-
enhance accessibility
-
save hours of manual work
For websites with large media libraries, this automation can significantly streamline image optimization.
FAQ
Does this overwrite existing alt text?
No. The script only fills alt text when it is missing.
Is this safe for large websites?
Yes. The bulk update tool can run in batches to prevent server overload.
Will this improve SEO rankings?
It improves image SEO and removes technical issues flagged in SEO audits.
Β