• When I go the my post page and edit my image under image details, the alt text listed is different than the alt text listed for the same image in the media library (attachment details). Could someone please let me know if there is something wrong? I am trying to figure out which one I should edit in the future.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Once an image has been added to the page, it is ‘disconnected’ from the media library. This means that when you change the alt text on either one, it won’t be updated on the other.

    This is because when you add an image to a post it is just added as an HTML <img> tag. When you edit that image in the post editor, you are only editing that image tag, not the attachment in the media library.

    The same goes for when you edit the image in the media library. When you do this you’re editing the reference to the image in the database. This means that the next time you add the image to the page, it will use the latest alt text, but when you edit the image from the media library WordPress does not update the image tag on existing posts and pages.

    To confuse things a little more, if an image is output onto a page programmatically (typically via a theme or plugin template) then it will be output with the latest alt text from the media library. This is because when the image is output via a template, such as in the case of the Featured Image, WordPress maintains a link between that image and the database.

    What’s likely happened here is that you had inserted an image into a post, and later changed the alt text in the media library. Since the post was not updated automatically, they now use different alt text.

    So the answer to your question about which to edit is essentially “both”. It’s a good idea to set the alt text in the media library, but you just need to make sure that if the image has already been used in a post that you go back to that post and update it there also.

    Thread Starter beantown123

    (@beantown123)

    Thank you for the detailed response. This answers my question. I appreciate it!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Alt text different between post page and media library’ is closed to new replies.