Opened 3 years ago

Last modified 2 years ago

#14282 new defect (bug)

the_post_thumbnail and get_the_post_thumbnail don't populate the images alt text correctly

Reported by: msigley Owned by:
Priority: normal Milestone: Future Release
Component: Post Thumbnails Version: 3.0
Severity: normal Keywords: reporter-feedback
Cc:

Description

Recently was adding in Post Thumbnails for a client's blog and discovered that the "the_post_thumbnail()" function doesn't return an img tag populated by the alt text set for the image in the media gallery.

Did come up with a workaround though:

$thumbnail_id = get_post_thumbnail_id();
$thumbnail_alt_text = get_post_meta($thumbnail_id,
'_wp_attachment_image_alt', true);
the_post_thumbnail(array(150,150), "alt=$thumbnail_alt_text");

This should be a simple fix of editing the function's output in wp-includes/post-thumbnail-template.php.

Change History (3)

  • Version changed from 2.9.2 to 3.0
  • Keywords needs-patch added; post thumbnail alt text removed
  • Milestone changed from Awaiting Review to Future Release
  • Keywords reporter-feedback added; needs-patch removed

Without testing, the code looks proper in wp_get_attachment_image here.

Note: See TracTickets for help on using tickets.