WordPress Image SEO; Automatically set Alt text tag, description and other metas permanently

wordpress image seo automatically set alt tahs description and other metas 310100154. - WordPress Image SEO; Automatically set Alt text tag, description and other metas permanently

Optimising images for SEO is something many often take lightly and you shouldn’t. If you are really serious about optimising your website for best search engine performance then WordPress image SEO is something to pay close attention to.

I’m going to reveal the golden nuggets of how to make your website, your WordPress website faster, and the biggest thing that I see is when people are uploading their image to their WordPress website they’re not optimizing it, so what that means is when someone visits your site your site will be slower because they’re trying to download this image that has not been optimized.


Issue 1: Image Size Resolution & Optimization techniques


I’m going to show you the process that I go through in order to get it as nimble as possible. A lot of people get their image ready and then they use that without minding how the big resolution of the images can hamper the speed of their website.

When you upload images to WordPress by default, you end up with large images that slow your website down and they also hurt your SEO with Google becauss your website is slow.

Course of Action

1. change the resolution of all images after upload.

2. Automatically compressed all images with plugins like TinyPNG or WpSmush.


Issue 2: Automatically set Alt tags, description, image URL and Image title tags.


When you add a new image to your WordPress website, if you being paying attention to this, you will notice that WordPress automatically generates only a title that is derived from the original image file name.

So what that means is that you get poor to no optimization for your images, it is zero especially if the files had generic names that contains a mix of letters and words as done my most camera devices and smartphones, example: IMG DSE90899.JPG. If you don’t manually set the, image, URL, Alt text tag, description and title which might have been auto generated with the default file name then you don’t have any search optimisation for that image.

Solution

But I bring you a very quick solution, a lasting one for that matter, if follow the method you are about to read now, it means you will only have to bother less about your WordPress image search engine optimization, because this simple method would have catered for that permanently till ages.

In this new method the Alt text tags, description, permalink, title, and caption will be automatically generates at every upload with the original file name, so now the only thing you would need to do is make sure you already optimise your images with your targeted keywords before uploading to your wordpress site.

READ ALSO  2018 Instagram logo vector

Once that is made sure then leave the rest to these plugin you about to add to your website to do the rest of the job for you, and it doesn’t do it in the background, when you go back to check your images, you will see it clearly that all the above meta fields has been automatically filled across all of your images.

How do you implement these method?

Follow these easy settings step by step and forget about image optimisation forever.

The method.

1. Go to “Appearance” in your WordPress dashboard, under appearance visit “Editor” to edit your core functions.Php file, once you are there, copy the below code, to the very last line of your functions.php and save the changes.

/* Automatically set the image Title, Alt-Text, Caption & Description upon upload
--------------------------------------------------------------------------------------*/
add_action( 'add_attachment', 'my_set_image_meta_upon_image_upload' );
function my_set_image_meta_upon_image_upload( $post_ID ) {

// Check if uploaded file is an image, else do nothing

if ( wp_attachment_is_image( $post_ID ) ) {

$my_image_title = get_post( $post_ID )->post_title;

// Sanitize the title: remove hyphens, underscores & extra spaces:
$my_image_title = preg_replace( '%s*[-_s]+s*%', ' ', $my_image_title );

// Sanitize the title: capitalize first letter of every word (other letters lower case):
$my_image_title = ucwords( strtolower( $my_image_title ) );

// Create an array with the image meta (Title, Caption, Description) to be updated
// Note: comment out the Excerpt/Caption or Content/Description lines if not needed
$my_image_meta = array(
'ID' => $post_ID, // Specify the image (ID) to be updated
'post_title' => $my_image_title, // Set image Title to sanitized title
'post_excerpt' => $my_image_title, // Set image Caption (Excerpt) to sanitized title
'post_content' => $my_image_title, // Set image Description (Content) to sanitized title
);

// Set the image Alt-Text
update_post_meta( $post_ID, '_wp_attachment_image_alt', $my_image_title );

// Set the image meta (e.g. Title, Excerpt, Content)
wp_update_post( $my_image_meta );

}
}

2. Hence, always make sure that all your images are properly named to include keywords related to your web pages, specific the keywords for each image and make them reasonably long tail, and don’t over do it by making it too long.


Code Credit: Brutal Business


If you follow these two line simple process properly you can go to tour media library CTO check if these work, you will see that all the fields in your image such Alt text, description, permalink, caption have been properly filled, if you feel you don’t want the caption you can remove that easily on the captions page.

Don’t leave these page unless you share.

No more articles