WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 11 months ago

Last modified 11 months ago

#14282 closed defect (bug) (invalid)

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

Reported by: msigley Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Post Thumbnails Keywords: reporter-feedback
Focuses: 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 (5)

comment:1 msigley4 years ago

  • Version changed from 2.9.2 to 3.0

comment:2 nacin4 years ago

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

comment:3 nacin4 years ago

  • Keywords reporter-feedback added; needs-patch removed

Without testing, the code looks proper in wp_get_attachment_image here.

comment:4 avryl11 months ago

  • Resolution set to invalid
  • Status changed from new to closed

No feedback in over three years.

comment:5 helen11 months ago

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.