Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
25 Million+
Websites using our plugins
Years of WordPress experience
WordPress tutorials
by experts

Beginner’s Guide to Image SEO – Optimize Images for Search Engines

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Are you looking to improve image SEO on your website? When optimized properly, image search can bring many new visitors to your website.

To benefit from image SEO, you need to help search engines find your images and index them for the right keywords.

In this beginner’s guide, we will show you how to optimize image SEO by following the top best practices.

Beginner's Guide to Image SEO - Optimize Images for Search Engines

Here is a brief overview of what you will learn in this article:

Optimizing Your Images for SEO and Speed

Speed plays an important role in SEO and user experience. Search engines consistently rank fast websites higher. This is also true for image search.

Images increase your overall page load time. They take longer to download than text, which means your page loads slower if there are several large image files to download.

That’s why you need to make sure that images on your WordPress website are optimized for the web. This can be a little tricky to get used to since many beginners are not experts in graphics and image editing.

The best way to optimize images is by editing them on your computer using photo editing software like Adobe Photoshop. This allows you to choose the right file format to create a small file size.

You can also use an image compression plugin for WordPress. Image-optimizer plugins allow you to automatically reduce file size while uploading an image to WordPress.

You can learn more in our handy guide on how to properly optimize images before you upload any images to your website.

Video Tutorial

Subscribe to WPBeginner

If you’d prefer written instructions, just keep reading.

What Is Alt Text?

Alt text or alternative text is an HTML attribute added to the img tag which is used to display images on a web page. It looks like this in plain HTML code:

<img src="/fruitbasket.jpeg" alt="A fruit basket" />

It allows website owners to describe the image in plain text. The main purpose of the alternate text is to improve accessibility by enabling screen readers to read out the alt text for visually-impaired users.

Alt text is also crucial for image SEO. It helps search engines understand the context of the image.

Modern search engines can recognize an image and its content by using artificial intelligence. However, they still rely on website owners to describe the image in their own words.

Alt text also accompanies images in Google image search, which helps users understand the image and improves your chances of getting more visitors to your WordPress blog.

Search image by title

Usually, alt text is not visible on your website.

However, if an image is broken or can’t be found, then your users will be able to see the alternate text with a broken image icon next to it.

Alt text displayed next to a broken image icon

What Is the Difference Between Alt Text vs. Titles?

Alt text is used for accessibility and image SEO, while the title field is used internally by WordPress for media searches.

Search image by title

WordPress inserts the alt tag into the actual code used to display the image. The title tag is stored in the WordPress database to find and display images.

In the past, WordPress also inserted the title tag in the HTML code. However, it was not an ideal situation from the accessibility point of view, which is why they removed it.

What Is the Difference Between Alt Text vs. Captions?

The alt text is used to describe the image for search engines and screen readers. On the other hand, the caption is used to describe the image for all users.

Alt text is not visible on your website, while captions are visible below your images.

Example of a caption displayed below an image

The alt text is crucial for better image SEO on your website. The caption is optional and can be used when you need to provide additional information about the image to website visitors.

How to Add Alt Text, Title, and Caption to Images in WordPress

Alt text, title, and caption make up the image metadata that you can add to images when uploading them into WordPress.

When you add an image using the default Image block, WordPress allows you to add a caption and alt text for it.

Adding alt text and caption to an image in WordPress

WordPress automatically generates a title for the image from the file name.

You can change the title by expanding the image’s ‘Advanced’ block settings. Here you will find a ‘Title Attribute’ field where you can add your own custom title for the image.

Adding an Image Title in the Block Editor

You can also edit the alt tag and title for the images that you have already uploaded to WordPress.

To do that, you need to visit the Media » Library page and find the image you want to edit.

WordPress Media Library

Simply clicking on an image will bring up the attachment details popup.

Here, you can enter alt text, a title, a caption, and an optional description that is displayed on the attachment page.

Add alt tag and title via media library

Note: Changing an image’s alt tag or caption via the Media Library will not change it in the posts and pages where the image is already used.

When to Use Captions for Images in WordPress

Captions allow you to provide additional details for an image to all your users. They are visible on the screen for all users, including search engines and screen readers.

An image gallery with captions for each image

As you may have noticed, most websites don’t normally use captions with images in their blog posts or pages. That’s because captions are often not needed to explain an image.

Captions are more suitable in the following scenarios:

  • Family or event photos
  • Photos that need additional explanation describing the background story
  • Product image galleries

In most cases, you will be able to explain the image in the article content itself.

All in One SEO (AIOSEO) is the best WordPress SEO plugin on the market, and its Image SEO addon will automatically set your alt text, image titles, captions, and more. It will also add a proper image sitemap and other SEO features to improve your SEO ranking.

The first thing you need to do is install and activate the All in One SEO plugin. For more details, see our step-by-step guide on how to install a WordPress plugin. To use the Image SEO feature, you will need the Plus plan or above.

Upon activation, the plugin will launch the setup wizard automatically. You can learn how to configure the plugin in our guide on how to set up All in One SEO correctly.

Now you need to navigate to All in One SEO » Search Appearance and then click on the ‘Image SEO’ tab. After that, click the ‘Activate Image SEO’ button to enable the premium image SEO features.

Activating the Image SEO Module in AIOSEO

Setting Automatic Image Titles Using All in One SEO

When you navigate to the ‘Title’ tab on the Image SEO page, you can choose a title format using smart tags that will be automatically used to generate title attributes for your images.

For example, adding the ‘+ Image Title’ tag will automatically use the image title used in the WordPress media library.

Customizing the Image Title in AIOSEO

You can also add other tags, such as your website title, strip punctuation from the title, and change its capitalization.

Setting Automatic Alt Text Using All in One SEO

Next, you can click on the ‘Alt Tag’ tab to automatically format the alt text of your images.

By default, AIOSEO will simply use the alt text from the media library. If you like, you can also add your website’s title and other information to the alt text of each image on your website.

Customizing the Alt Tag in AIOSEO

All in One SEO’s Image SEO addon can also automatically generate image captions, disable attachment pages as we’ll cover below, and much more.

How to Disable Attachment Pages in WordPress

WordPress creates a page for each image you upload to your posts and pages. It is called the attachment page. This page just shows a larger version of the actual image and nothing else.

This can have a negative SEO impact on your search rankings. Search engines consider pages with little to no text as low-quality or thin content.

This is why we recommend that you disable the attachment pages on your website.

Disabling Attachment Pages Using All in One SEO

The easiest way to do this is by installing and activating the All in One SEO plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Upon activation, it automatically turns off attachment URLs. You can also manually turn off attachment pages in WordPress by visiting the All in One SEO » Search Appearance page and clicking on the ‘Image SEO’ tab.

Redirect media attachment URLs in AIOSEO

From here, make sure that the ‘Redirect Attachment URLs’ option is set to ‘Attachment’.

Attachment pages will now be redirected to the images themselves. This means that whenever a search engine or visitor goes to the URL for an attachment page, they will see the image instead of the attachment page.

Disabling Attachment Pages Using a Plugin

If you are not using the AIOSEO plugin, then you can install the Attachment Pages Redirect plugin. This plugin simply redirects people visiting the attachment page to the post where the image is displayed.

Disabling Attachment Pages Using Code

You can also disable attachment pages by adding code to your theme’s functions.php file. The safest way to do this is with WPCode, the most popular code snippets plugin that makes it easy to add code snippets in WordPress.

The best thing is that WPCode comes with a built-in snippets library where you can find all of the most popular WordPress code snippets, including disabling attachment pages.

First, you need to install and activate the free WPCode plugin. For more details, please see our guide on how to install a WordPress plugin.

Upon activation, head over to Code Snippets » + Add Snippet. You need to search the snippets library to locate the Disable Attachment Pages snippet.

The WPCode Library Includes a Snippet to Disable Attachment Pages

When you hover your mouse over the snippet, you will see some buttons.

Simply click the ‘Use snippet’ button, and a new snippet will be created for you.

Activate and Update the WPCode Snippet

All you need to do now is toggle the ‘Active’ switch to the On position and then click the ‘Update’ button. You have now successfully disabled attachment pages.

If you are familiar with code, then you can also do this manually by adding the following code directly to your theme’s functions.php file.

function wpb_redirect_attachment_to_post () {
if ( is_attachment() ) {
global $post;
if( empty( $post ) ) $post = get_queried_object();
if ($post->post_parent)	{
	$link = get_permalink( $post->post_parent );
	wp_redirect( $link, '301' );
else	{
	// What to do if parent post is not available
	wp_redirect( home_url(), '301' );
add_action( 'template_redirect', 'wpb_redirect_attachment_to_post' );

Additional Tips to Improve Image SEO

Adding an alt tag is not the only thing you can do to improve image SEO. Following are a few additional tips that you should keep in mind when adding images to your blog posts.

1. Write Descriptive Alt Text

Many beginners often just use one or two words as the alt text for the image. This makes the image too generic and harder to rank.

For example, instead of just ‘kittens’, you can use ‘Kittens playing with a yellow rubber duck’.

2. Use Descriptive File Names for Your Images

Instead of saving your images as DSC00434.jpeg you need to name them properly. Think of the keywords that users will type in the search to find that particular image.

Be more specific and descriptive in your image file names. For example, red-wooden-house.jpeg is better than just house.jpeg.

3. Provide Context to Your Images

Search engines are getting smarter every day. They can recognize and categorize images quite well. However, they need you to provide context to the image.

Your images need to be relevant to the overall topic of the post or page. It is also helpful to place the image near the most relevant text in your article.

4. Follow the SEO Best Practices

You also need to follow the overall SEO guidelines for your website. This improves your overall search rankings, including image search.

5. Use Original Photographs and Images

There are many free stock photography websites that you can use to find free images for your blog posts. However, the problem with stock photos is that they are used by thousands of websites.

Try to use original photographs or create quality images that are unique to your blog.

Expert Guides on Optimizing WordPress Images

Image SEO is just one aspect of optimizing images in WordPress. You might like to see some other guides related to improving images on your WordPress website.

We know that most bloggers are not photographers or graphic designers. Luckily, there are some great online tools that you can use to create graphics for your websites.

We hope this article helped you learn about Image SEO for your website. You may also want to see our guide on how to fix common image issues in WordPress or our expert picks for the best WordPress SEO plugins and tools.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

42 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. bonmot says

    Code after “If you are familiar with code, then you can also do this manually by adding the following code directly to your theme’s functions.php file.” seems to be incomplete. Shouldn’t there be:

    function wpb_redirect_attachment_to_post () {


    if ( is_attachment() ) {


  3. Jiří Vaněk says

    Does image format have any effect on SEO? Is it jpeg, webp or png? I use webp because of the size, is there a better chance for SEO that google may prefer this type of image for its size?

    • WPBeginner Support says

      Unless we hear otherwise, there is not a SEO advantage to the image format, it would be best to use the image format that fits the use of the image best.


      • Jiří Vaněk says

        Thanks for the reply, I was hoping that Google would prefer a custom image format and also that it would prefer the size. Damage. Anyway, thanks for the reply. I use webp on the Web and will continue to use it.

  4. Patricia says

    “Note: Changing an image’s alt tag or caption via Media Library will not change it in the posts and pages where the image is already used.”

    If this is the case how can i adjust the alt tags of the images already in use?

  5. Joe Staiano says

    Is it OK to edit all these photos in my WP Dashboard Media Library if the website and individual pages are already published and live? Do I need to delete each photo and reload a copied version of photo that has correct Alt Tags, Title, Description?

    • WPBeginner Support says

      If you made changes in the media library to image tags, you would need to re-add the images for the information to be what you have changed it to for media already on your site.


  6. Nelda Schulte says

    That was a great explanation. I’ve been searching for this specific type of information for days, your’s was the best I found. Thank you!

  7. Favian says

    Re: image size – I have uploaded images 1200x1200px @around <1mb. Does it make sense to reduce the file size directly in WP (e.g. insert images not in 'full size' but rather in 'large', 'medium' etc)? Or do i have to take care of image size when directly uploading the images from my hard drive? Thanks

    • WPBeginner Support says

      At that point, it becomes more of a personal preference question but we prefer to optimize and resize images before uploading them to a WordPress site if that is what you mean.


  8. sanjay sajeev says


    Thank you for sharing the image optimization tips. My concern is a different thing. For example, I published one blog post including an image. Later, I want to remove that image from the post and add a new one. If I remove it and add a new image. Will it affect my sites SEO?

    • WPBeginner Support says

      It shouldn’t have a major ranking change for your site’s SEO if you change the image.


    • WPBeginner Support says

      That field is for displaying text on the image attachment page or below the image depending on your theme’s design rather than something major for SEO at the moment


  9. Denisse says

    Hello! Thank you so much for this information. I have been looking for a post like this for a while now.

    For the pictures of myself that go under my “About me” section in my blog, do they still need metadata?

  10. Avinash says


    Thanks for the great article.

    Are there any specific guideline for adding alt text to bog cover image

    • WPBeginner Support says

      You would follow it the same as you would for other images, when selecting the image you should have the option to edit the tags with the media uploader


  11. Tom says


    Great article!!!
    I got a question, you said : “Changing an image’s alt tag or caption via Media Library will not change it in the posts and pages where the image is already used.”
    Does that mean I need to reinsert image again after add alt tag in Media Library?
    Thank you

    • WPBeginner Support says

      After you set it up in the media library, once you attempt to add it to a post, it should bring in tags you set in the media library


  12. Franci Hoffman says

    This is most helpful, Syed, especially your explantation about “How to Add Alt Text, Title, and Caption to Images in WordPress”.

    Thank you.

  13. Rob says

    I’ve been doing SEO since before Google existed. I came to read this just for fun and because I trust WP beginner.

    I actually learned something.

    I had no idea the alt tag was used in Google image search to describe the image.

  14. Linda says

    Due to time constraints and sheer volumes of photos I am asked to post on over 5 websites I manage for my organization, I often neglect the metadata and regret it later on. This is a very important article and a great incentive for all of us to organize our media libraries from the get go and discipline ourselves with each image added to provide this info. (Not to mention our posts and pages!)

    Thank you.

  15. John Monyjok Maluth says

    Wow! Great article again. I need this to improve my images. Yes, I’m using Yoast SEO, but never thought of using it to improve images on my site, especially turning off the “attachment pages”.

    Thanks for helping me find the best WordPress tips when I need them. You have taught me a lot of things.

    John Shalom

  16. Nur Salam says

    Should I use original files from stock photo. Because the images are high resolution and size. And gtmetrics suggested to use optimised photos…

    • WPBeginner Support says

      Depending on where you got the stock photo from, you would want to check their license agreement to be sure that is allowed.


    • WPBeginner Support says

      If your browser automatically accepted our push notifications for some reason, you should be able to right-click the notifications to stop them.


Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.