Skip to content

Published

Alt Text in WordPress: Where It Is Stored and How to Add It

In short

Add alt text from the Image block or Media Library. Our WordPress 7.1.5 test shows why old posts keep old alt and which alt featured images use.

Details
Free tool for this
WordPress Image Size Lab

Short answer: select the image in the block editor, open the Block tab of the settings sidebar, and type in Alternative text. The alt text you enter in Media > Library is only a starting value. WordPress copies it into a post when you insert the image, so changing it later doesn’t touch posts that already use that image. Featured images are different: on a single post they read the current Media Library alt each time the page loads, and where the theme links them to the post they use the post title. We tested where alt text ends up on WordPress 7.1.5 with the Twenty Twenty-Five theme.

What we tested

  • Odie Themes ran the test on 2 December 2026: WordPress 7.1.5, PHP 8.3, Twenty Twenty-Five 1.5 and no active plugins, in WordPress Playground, with the admin screens driven in a Chromium browser.
  • We typed alt text in the Media Library, inserted images with the Image and Gallery blocks, changed the alt afterwards, set featured images, ticked Mark as decorative and uploaded test images with and without alt text embedded in the file. Then we read the saved post HTML and the front-end pages.
  • All 8 checks came out as this guide describes. What we could not test is listed under How we tested.

Alt text is the short description in an image’s alt attribute. IPTC’s definition describes it as text about the purpose and meaning of an image that assistive technology can read, or that a browser shows when the image is turned off. The same <img> tag also decides which file loads, and the WordPress Image Size Lab shows every size WordPress makes from an upload.

How to add alt text in the block editor

The alt text in the Image block is the one visitors get for that image in that post.

  1. Click the image in your post or page to select its Image block.
  2. If the settings sidebar is closed, open it with the sidebar button at the top right, next to Publish or Save.
  3. Choose the Block tab.
  4. Type your description in Alternative text.
  5. Save, publish or update the post. WordPress writes the alt text into the post when it saves.

If the image already had alt text in the Media Library, the field is filled in when you pick the image, because the block copies it. What you change here belongs to this post only: in our test, emptying the block’s alt with Mark as decorative left the image’s Media Library alt as it was.

WordPress block editor Block tab for a selected Image block, with the Alternative text field filled in, a Describe the purpose of the image link and a Mark as decorative checkbox
The Block tab on our WordPress 7.1.5 test site (2 December 2026). The Alternative text field already holds the text typed in the Media Library, because the block copied it when the image was picked.

The alt text ends up in the post’s HTML, inside the <img> tag. It is not in the block’s settings comment above it. This is the saved post from our test (the src is shortened):

HTML
<!-- wp:image {"id":4,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large"><img src=".../alt-a-1024x683.jpg" alt="Red test card with the word TEST written six times" class="wp-image-4"/></figure>
<!-- /wp:image -->

A Gallery block holds one Image block per picture. Click a picture inside the gallery to select it, and the Block tab shows that picture’s own Alternative text field. When we built a gallery from the Media Library, each picture started with its Media Library alt, the same as a single Image block, and the picture with no alt got alt="". Changing a picture’s Media Library alt afterwards did not change the gallery.

How to add alt text in the Media Library

  1. Go to Media > Library and click the image.
  2. In Attachment details, type in Alternative Text.
  3. Press Tab or click into another field. WordPress saves the alt text by itself and shows “Saved.” at the top of the panel. There is no Save button.
WordPress Media Library Attachment details panel showing Saved, the file details, and the Alternative Text field filled in above the Title, Image Caption and Description fields
Media > Library on the same test site. Alternative Text, Title, Image Caption and Description are four separate fields.

The Media Library alt is used for images you insert after typing it, for featured images on single posts, and for anything your theme or a plugin prints with WordPress’s own image functions, such as wp_get_attachment_image().

WordPress stores it on the image itself (the attachment), in a custom field named _wp_attachment_image_alt. In our test, an image that never had alt text had no such field at all.

Why your Media Library alt text doesn’t show in old posts

WordPress copied the alt text into each post when the image was inserted. After that, the post has its own copy, and a later change in the Media Library doesn’t reach it.

We changed an image’s Media Library alt from a first version to a second. The post that already used the image kept the first version everywhere we looked: in the database, on the live page, and in the block when we reopened the post in the editor. A new post that inserted the same image afterwards got the second version.

The reason is in how WordPress builds the page. When a post loads, wp_filter_content_tags() adds width, height, srcset, sizes and loading attributes to its images from the image’s data (the srcset is what points browsers at the extra sizes WordPress makes from every upload). In the 7.1.5 code that filter has no step for alt text, so visitors get the alt saved in the post.

Where the image appearsAlt text visitors getFollows later Media Library edits?
Image block in a postThe alt copied in at insert, or what you typed in the blockNo
Gallery blockSame as the Image block, per pictureNo
Image inserted after your editThe new Media Library altIt starts with the new text
Featured image on a single post (Twenty Twenty-Five)The Media Library altYes
Featured image linked to its post (Twenty Twenty-Five blog page)The post titleNo, it never used the image’s alt
Classic theme featured image, the_post_thumbnail()The Media Library alt, unless the theme passes its ownYes, when the theme passes none (we ran the function it calls; no classic theme was installed)

How to fix alt text on images already in posts

Open the post, select the image, edit Alternative text in the Block tab and update the post. Inserting the image again as a new block also picks up the current Media Library alt, as our control post did. If your site uses a page cache, clear it so visitors get the new HTML. Nothing in our test updated old posts by itself, so plan on one edit per post. We did not test plugins that edit alt text in bulk.

A featured image uses the Media Library alt, except where the theme shows it as a link to the post and sets the alt to the post title. Every block theme does this through the Post Featured Image block, and some classic themes do it too.

On Twenty Twenty-Five 1.5, the single post template shows the featured image without a link, and it printed the image’s current Media Library alt (alt="" for the image that had none). The blog page links each featured image to its post, and there both images got their post’s title, including the image with its own alt text: it came out as alt="P1 image block with A", the title of our test post. The title stayed after we changed the image’s Media Library alt.

The switch is in the Post Featured Image block. When the block is set to link the image to the post, its PHP code (render_block_core_post_featured_image()) replaces the alt with the post title. Because this happens in the block’s code, any block theme whose template links its featured images gets the same result; open your theme’s templates in Appearance > Editor to see which ones do. W3C’s guidance for an image used as a link is that its text alternative should say where the link goes (Functional Images), which matches what the block does.

Classic themes print the featured image with the_post_thumbnail(), which uses the Media Library alt unless the theme passes its own. We ran get_the_post_thumbnail(), the function behind it, and with no alt passed it printed the current Media Library alt. Some classic themes do pass one: Twenty Sixteen 3.9 gives linked featured images in its post lists the post title as alt (twentysixteen_post_thumbnail() in its inc/template-tags.php, code read, not tested). For the size of that image, see which featured image size to upload for your theme.

Decorative images and empty alt

If an image is pure decoration, tick Mark as decorative under Alternative text in the Image block. In our test WordPress saved it as alt="" role="none" and left the image’s Media Library alt alone, so the same image can still carry a description in other posts.

What you do in the Image blockHTML WordPress saved in our test
Alternative text filled in (in our test, copied from the Media Library)alt="your text"
Leave Alternative text emptyalt="": the attribute is there, with nothing in it
Tick Mark as decorativealt="" role="none"

WordPress never filled an empty alt with the image title or file name in our test, in the Image block or in wp_get_attachment_image(). An empty alt is what W3C’s alt decision tree asks for when an image is purely decorative or repeats text that is already next to it. On an image that carries meaning, it gives people who can’t see the image nothing to go on.

”This image has an empty alt attribute; its file name is …”

In WordPress core this wording exists in one place, the Image block’s editing view. It uses the wording as the alt of the picture shown inside the editor when the image has no alt text yet. When we saved a post with such an image, the page had a plain alt="". So the message is telling you the image has no alt text: type one, or tick Mark as decorative if the image is decoration. We found the wording by reading WordPress 7.1.5’s editor code; we did not capture the message on screen.

Let WordPress fill alt text from the image file

Since WordPress 7.0, if an image file carries the IPTC “Alt Text (Accessibility)” field, WordPress copies that text into the image’s alt text when you upload it. The function that reads it is wp_get_image_alttext(), introduced in 7.0.0.

In our test on 7.1.5 this worked from Media > Add New and from the Image block’s Upload button, and with the block upload the text went straight into the post. The same picture without the field got no alt text on either path. To add the field yourself, this is the exiftool command we used (exiftool 13.64), with your own text in the quotes:

Shell
exiftool -XMP-iptcCore:AltTextAccessibility="Your alt text" photo.jpg

What to know before you rely on it:

  • It is copied once, at upload. Changing the field in the file later does nothing to an image already in WordPress. Nothing in the 7.1.5 code copies it into the alt text again.
  • Only the XMP form is read. WordPress looks for Iptc4xmpCore:AltTextAccessibility in the file’s XMP data, not in the older IPTC-IIM block (code read).
  • Languages: with several language versions in the field, WordPress takes the one matching the site’s locale, then its two-letter language, then the default entry (code read; we tested one default entry).
  • Metadata cleaners remove it. A tool that strips all metadata before upload strips this field too, so WordPress has nothing to read. That follows from the same code; we did not run it as a separate test.
  • Length: the IPTC standard says this field’s text should not exceed 250 characters.

How to write good alt text

The Describe the purpose of the image link under the block’s field opens W3C’s alt decision tree. In short:

  • Say what the image does on this page. For a simple photo or graphic that adds meaning, a brief description of that meaning is enough.
  • Text in the image goes in the alt, unless the same text is already on the page next to it.
  • A linked image describes where the link goes, not what the picture looks like.
  • Decoration gets an empty alt, and so does an image that repeats nearby text. Use Mark as decorative.
  • Charts and diagrams need their data in the page text. The alt can’t hold it all.

Two habits to drop: starting with “image of” or “picture of”, which spends words without describing anything, and packing in keywords, which helps no one reading the alt. You will often see “keep it under 125 characters” as advice. That is a common rule of thumb, not something W3C’s decision tree sets.

For developers: read the alt in code

PHP
// The Media Library alt of attachment 123 ('' when there is none).
$alt = get_post_meta( 123, '_wp_attachment_image_alt', true );

// An <img> tag with that alt, or alt="" when the field is empty.
echo wp_get_attachment_image( 123, 'medium' );

// A post's featured image with the same alt (what the_post_thumbnail() prints).
echo get_the_post_thumbnail( $post_id, 'medium' );

All three read the Media Library alt at the moment the page loads, which is why they follow later edits. The alt of an image inside post content is different: it sits in the <img> tag in post_content, and in our test the block comment (wp:image with its JSON settings) did not contain it.

How we tested

  • Site: WordPress 7.1.5, PHP 8.3.37, SQLite, Twenty Twenty-Five 1.5, no active plugins, in WordPress Playground on a Mac, on 2 December 2026. Admin screens were driven with Playwright in Chromium 159.
  • Real clicks and typing: picking images in the Media Library window, typing alt text in Media > Library, Mark as decorative, and creating the gallery. Empty blocks were added by script and posts were published with the editor’s own save function. Featured images were set with set_post_thumbnail(), which writes the same setting as the Featured image panel.
  • What we read: each post’s saved HTML in the database, the front-end pages, and the image’s _wp_attachment_image_alt field. Front-end pages were fetched while logged in as admin; WordPress’s alt output does not depend on being logged in (code read).
  • Test images: 1200 x 800 JPEGs made by a script. The embedded-alt copies were written with exiftool 13.64, and the controls were the same picture without the field.
  • Not tested: the Classic Editor plugin and real classic theme templates, page builders, WooCommerce product images, alt-text and SEO plugins, images inserted from a URL, the Crop tool in the block toolbar, alt text kept only in the old IPTC-IIM format, and any effect on screen readers or search rankings.

Next: check the image size

If the alt text is right but the image looks soft or loads the wrong file, look at its size next, and see why WordPress images look blurry after upload for the usual causes. The WordPress Image Size Lab shows every size WordPress will create from your image, and the featured image size guide covers the image at the top of each post.

Sources

WordPress Image Size Lab Drop an image in. See every copy WordPress will make of it.
William Lopez

William Lopez runs Odie Themes, which publishes the free WordPress tools, themes and guides on this site.

About

Questions

Why doesn't my alt text show up after I changed it in the Media Library?

The Image block copies an image's alt text into the post when you insert it. In our WordPress 7.1.5 test, changing the Media Library alt afterwards left the existing post with the old text. Open each post, select the image, edit Alternative text in the Block tab and update the post. Images inserted after your change get the new text.

What does "This image has an empty alt attribute" mean in WordPress?

It means the image has no alt text yet. In WordPress core that wording comes only from the Image block's editor script. When we saved a post with such an image, the page had a plain alt="". Type a description in Alternative text, or tick Mark as decorative if the image adds nothing.

How do I mark an image as decorative in WordPress?

Select the image in the block editor, open the Block tab of the settings sidebar and tick Mark as decorative under Alternative text. WordPress describes this as hidden from assistive technologies. In our test it saved the image with alt="" and role="none", and the alt text stored in the Media Library stayed as it was.

Does WordPress add alt text automatically?

It fills the alt text field only from the image file. Since WordPress 7.0, an upload that carries the IPTC Alt Text (Accessibility) field gets that text as its alt, which our 7.1.5 test confirmed. Without it the alt stays empty: WordPress did not fall back to the image title or file name. We have not tested any AI alt-text plugin.

Is the image title or caption used as alt text in WordPress?

No. Alternative Text, Title, Caption and Description are separate fields, and WordPress's code for the Image block and for wp_get_attachment_image() reads only the Alternative Text field for the alt attribute. In our test an image titled alt-b with no alt text was printed with alt="", both in a post and through wp_get_attachment_image().