Make WordPress Core


Ignore:
Timestamp:
10/15/2013 11:23:08 PM (13 years ago)
Author:
lancewillett
Message:

Twenty Fourteen: better logic for featured image HTML output, and add fallback message for focusable anchor elements, for accessibility. Fixes #25325.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfourteen/inc/template-tags.php

    r25769 r25802  
    156156
    157157/**
    158  * Display featured image with appropriate HTML tag.
    159  *
    160  * @since Twenty Fourteen 1.0
     158 * Displays an optional featured image, with an anchor element
     159 * when on index views, and a div element when on a single view.
    161160 *
    162161 * @return void
    163  */
    164 function twentyfourteen_featured_thumbnail() {
    165         if ( ! post_password_required() ) :
    166                 if ( has_post_thumbnail() && is_singular() ) :
    167                 ?>
    168                         <div class="attachment-featured-thumbnail">
    169                                 <?php the_post_thumbnail( 'featured-thumbnail-large' ); ?>
    170                         </div>
    171                 <?php
    172                 else :
    173                 ?>
    174                         <a href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>" class="attachment-featured-thumbnail">
    175                                 <?php the_post_thumbnail( 'featured-thumbnail-large' ); ?>
    176                         </a>
    177                 <?php
    178                 endif;
    179         endif;
     162*/
     163function twentyfourteen_post_thumbnail() {
     164        if ( post_password_required() )
     165                return;
     166
     167        if ( is_singular() ) :
     168        ?>
     169
     170        <div class="featured-thumbnail">
     171                <?php the_post_thumbnail( 'featured-thumbnail-large' ); ?>
     172        </div>
     173
     174        <?php else : ?>
     175
     176        <a class="featured-thumbnail" href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>">
     177        <?php if ( has_post_thumbnail() ) :
     178                the_post_thumbnail( 'featured-thumbnail-large' );
     179        else : ?>
     180                <p class="screen-reader-text"><?php _e( 'No featured image.', 'twentyfourteen' ); ?></p>
     181        <?php endif; ?>
     182        </a>
     183
     184        <?php endif; // End is_singular()
    180185}
Note: See TracChangeset for help on using the changeset viewer.