I have a WordPress website "https://drgadyabramson.com" I am optimizing the website for better ranking. But the problem is Yoast SEO showing me that "The images on this page do not have alt attributes containing the focus keyword." The thing is I have placed alt tag to each and every image used on that page.

Alt tag inserted from the media library

But when I check the source code then it shows different ALT tag that i have inserted in media library. Check below:

Different ALT then inserted

It looks like my website automatically fetch ALT from title. But It's not good for SEO.

Any of you please suggests me the solution? Do I need to change in the theme file? If yes then what it would be?

2 Answers 2


Adding an alt attribute in the media library does not add or update it on any of your pages where it's already been inserted in content.

When you add an image to content using the editor, it's added as an HTML <img> tag, including alt attribute. Once it's been added, it's just HTML, so making changes in the media library can't affect it.

To add alt text to your images you'll need to go into each page, select and edit the images there, and add the alt text that you want.

  • But there are no options to add alt tag by going to the text mode. because of my website use visual composer.
    – Adam Levis
    Mar 2, 2019 at 16:02
  • Then you'll need to take that up with the authors of Visual Composer. Mar 2, 2019 at 16:03
  • Jacob do you know the code that works?
    – Adam Levis
    Mar 2, 2019 at 16:05
  • It's not a code issue. The problem is with your content. You need to edit your content to add the alt text. If you cannot do that then the problem is with Visual Composer, and you need to ask them for help. Mar 2, 2019 at 16:06
  • No. It's not a problem with Visual Composer. I have several websites running on visual composer but those websites don't have this issue.
    – Adam Levis
    Mar 2, 2019 at 16:08

You can call the alt_text if you are pulling the image with custom code. I hope this might help you if you are just searching for the $alt text

$alt_text = get_post_meta($post->ID, '_wp_attachment_image_alt', true);

Edit 1:

If you are pulling the image through wordpress function then only you can see the alt tag also being pulled in the output. <?php echo wp_get_attachment_image( get_the_ID(), array('700', '600'), "", array( "class" => "img-responsive" ) ); ?>

If you have an image being called manually with the only URL, then you can add alt as the variable which possibly should pull alt detail as following:

<img src="your method to call URL" alt="<?php echo $alt_text; ?>

  • Thanks but where do I add this code? functions.php?
    – Adam Levis
    Mar 2, 2019 at 16:02
  • Please check again for the edited section in Answer.
    – uservs301
    Mar 7, 2019 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.