Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#11846 closed defect (bug) (fixed)

Alt text for images wrong or empty in wp_get_attachment_image()

Reported by: kallewangstedt Owned by:
Priority: normal Milestone: 3.0
Component: Media Version: 2.9
Severity: major Keywords: has-patch
Cc: Focuses:

Description

When wp_get_attachment_image() is called, it generates the alt-text from the post_excerpt field instead of the (new) postmeta field with meta_key "_wp_attachment_image_alt". This causes the alt text to not be set even though the media editor clearly states that the "Alternate text" field is being used as alt text for the image.

I have attached a patch that corrects this by calling get_post_meta() instead of post_excerpt inside the function.

As a fallback it would be good to expand the function to check if there is an alt-text entry, and if not use the caption (post_excerpt) field instead, or if only the Title is set use that.

The alt text should not be empty at all.

Attachments (1)

media.php.diff​ (553 bytes ) - added by kallewangstedt 17 years ago.
Patch for wp_get_attachment_image()

Download all attachments as: .zip

Change History (5)

@kallewangstedt
17 years ago

Patch for wp_get_attachment_image()

#1 @scribu
17 years ago

  • Keywords has-patch added
  • Milestone Unassigned → 3.0

#2 @maorb
17 years ago

  • Cc maorb added

Thanks for your patch, I've just encountered this problem of missing alt text using the wp_get_attachment_image function, and didn't understand where have they disappeared...

Will this bug be fixed on ver 3.0?

#3 @kallewangstedt
17 years ago

It is NOT fixed in 3.0 as far as I can tell.

#4 @dd32
17 years ago

  • Resolution → fixed
  • Status new → closed

(In [14145]) Use Alt Text for Image alt caption (Falling back to Caption, and finally title) in wp_get_attachment_image() and subsequently, WordPress Galleries. Props kallewangstedt for initial patch. Fixes #11846

Note: See TracTickets for help on using tickets.