WordPress.org

Make WordPress Core

Changeset 32998


Ignore:
Timestamp:
06/29/2015 09:31:21 PM (5 years ago)
Author:
obenland
Message:

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.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/custom-header.php

    r32974 r32998  
    280280            $header_url = $header['url'];
    281281            $header_desc = empty( $header['description'] ) ? '' : $header['description'];
     282            $header_alt_text = empty( $header['alt_text'] ) ? $header_desc : $header['alt_text'];
    282283            echo '<div class="default-header">';
    283284            echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />';
     
    285286            if ( !empty( $header['attachment_id'] ) )
    286287                $width = ' width="230"';
    287             echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_desc ) .'" title="' . esc_attr( $header_desc ) . '"' . $width . ' /></label>';
     288            echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) .'" title="' . esc_attr( $header_desc ) . '"' . $width . ' /></label>';
    288289            echo '</div>';
    289290        }
  • trunk/src/wp-includes/theme.php

    r32964 r32998  
    12101210        $header_data = wp_get_attachment_metadata( $header->ID );
    12111211        $header_index = basename($url);
     1212
    12121213        $header_images[$header_index] = array();
    1213         $header_images[$header_index]['attachment_id'] =  $header->ID;
     1214        $header_images[$header_index]['attachment_id'] = $header->ID;
    12141215        $header_images[$header_index]['url'] =  $url;
    1215         $header_images[$header_index]['thumbnail_url'] =  $url;
     1216        $header_images[$header_index]['thumbnail_url'] = $url;
     1217        $header_images[$header_index]['alt_text'] = get_post_meta( $header->ID, '_wp_attachment_image_alt', true );
     1218
    12161219        if ( isset( $header_data['width'] ) )
    12171220            $header_images[$header_index]['width'] = $header_data['width'];
Note: See TracChangeset for help on using the changeset viewer.