How to Optimize Images for SEO

The three plugins listed below allow you to optimize your image names for SEO (Media File Renamer Pro), as well as source your alt -text from your WordPress media library (or vice versa) using Media Library Assistant and MLA Insert Fixit.

Media File Renamer (Pro)Renames your media files for better SEO and a nicer filesystem (automatically or manually).Version 5.3.4
Media Library AssistantEnhances the Media Library; powerful [mla_gallery] [mla_tag_cloud] [mla_term_list], taxonomy support, IPTC/EXIF/XMP/PDF processing, bulk/quick edit.Version 2.98
MLA Insert FixitSynchronizes Media Library values to and from post/page inserted/featured/attached imagesVersion 1.22

I wanted to rename my WordPress featured images to their corresponding post-title, but couldn’t without first changing each image’s title.

The plugin I used was Media File Renamer Pro and it required a rename-source (text on which to base image renames). Because I don’t usually give my images a title, this was more challenging than it should have been. So, I had to first change the image-titles. I could do it manually or programmatically.

Which do you think I choose? ๐Ÿ˜‰

First, I grabbed all featured images using this SQL statement.

select post_id, meta_value as image_post_id, post_title from wp_postmeta inner join wp_posts on wp_posts.id = wp_postmeta.post_id where meta_key = ‘_thumbnail_id’;

This gives you the post_id of the post, as well as the post_id of the image (that I’ve aliased as image_post_id) — in other words, WordPress is linking an image to a post. In our case, we want the “image_post_id.”

And for reference (above), “_thumbnail_id” is a constant defined by WordPress, indicating the image is featured, or in WordPress parlance, a thumbnail.

Also, in WordPress, images, posts, pages, etc. are all considered “posts.” This can be confusing. So, a post is indeed a post. And a page is also a post. They are saved in the wp_posts database table.

The image-title is actually called the “post_title” inside the table — and this makes sense because an image is a post (see above).

// <image title> should be replaced with text and <#> should be replaced with your image’s post-id. — not your post’s post-id (careful!)
update wp_posts set post_title = “<image title>” where id = <#>;

Why are we doing this?

Because Media File Renamer will use the image-title to rename the images (if you select this).

If you’d like to change your image’s alt-text in the WordPress media library, use the following SQL statement. Remember, you’re using your image’s post_id here.

insert into wp_postmeta(meta_value,post_id,meta_key) values (“<alt-text>”,<#>,”_wp_attachment_image_alt”);

For reference, “_wp_attachment_image_alt” is a constant defined by WordPress, which indicates this is the alt-text for the corresponding image.

SOURCE (How to use Media Library Assistance and MLA Insert Fixit): Pigzilla