Provide alt text for uploaded header images.

The custom header screen will use it rather then the description,
if an alt text is set.

Props francoeurdavid, voldemortensen, valendesigns.
Fixes #27959.


Built from https://develop.svn.wordpress.org/trunk@32998


git-svn-id: http://core.svn.wordpress.org/trunk@32969 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Konstantin Obenland 2015-06-29 21:32:26 +00:00
parent 2a5bf835da
commit 36b24b073d
3 changed files with 8 additions and 4 deletions

View File

@ -279,12 +279,13 @@ class Custom_Image_Header {
$header_thumbnail = $header['thumbnail_url'];
$header_url = $header['url'];
$header_desc = empty( $header['description'] ) ? '' : $header['description'];
$header_alt_text = empty( $header['alt_text'] ) ? $header_desc : $header['alt_text'];
echo '<div class="default-header">';
echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />';
$width = '';
if ( !empty( $header['attachment_id'] ) )
$width = ' width="230"';
echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_desc ) .'" title="' . esc_attr( $header_desc ) . '"' . $width . ' /></label>';
echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) .'" title="' . esc_attr( $header_desc ) . '"' . $width . ' /></label>';
echo '</div>';
}
echo '<div class="clear"></div></div>';

View File

@ -1209,10 +1209,13 @@ function get_uploaded_header_images() {
$url = esc_url_raw( wp_get_attachment_url( $header->ID ) );
$header_data = wp_get_attachment_metadata( $header->ID );
$header_index = basename($url);
$header_images[$header_index] = array();
$header_images[$header_index]['attachment_id'] = $header->ID;
$header_images[$header_index]['url'] = $url;
$header_images[$header_index]['thumbnail_url'] = $url;
$header_images[$header_index]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );
if ( isset( $header_data['width'] ) )
$header_images[$header_index]['width'] = $header_data['width'];
if ( isset( $header_data['height'] ) )

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32997';
$wp_version = '4.3-alpha-32998';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.