WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/21/2016 10:14:26 PM (4 years ago)
Author:
davidakennedy
Message:

Twenty Seventeen: Display featured image on static front page

This improves UX, since an image added will be displayed on front end as opposed to not at all. This fix added the front page's featured image above the front page content, similar to how it's handled in the other panels. Also it removed code that was setting the front page's featured image as a fallback to the custom header, and updated the conditions that add the has-header-image to remove reference to the front page's featured image.

Props laurelfulford.

Fixes #38402.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyseventeen/components/page/content-front-page.php

    r38833 r38868  
    1111?>
    1212<article id="post-<?php the_ID(); ?>" <?php post_class( 'twentyseventeen-panel ' ); ?> >
     13
     14    <?php if ( has_post_thumbnail() ) :
     15        $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' );
     16
     17        $post_thumbnail_id = get_post_thumbnail_id( $post->ID );
     18
     19        $thumbnail_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' );
     20
     21        // Calculate aspect ratio: h / w * 100%.
     22        $ratio = $thumbnail_attributes[2] / $thumbnail_attributes[1] * 100;
     23        ?>
     24
     25        <div class="panel-image" style="background-image: url(<?php echo esc_url( $thumbnail[0] ); ?>);">
     26            <div class="panel-image-prop" style="padding-top: <?php echo esc_attr( $ratio ); ?>%"></div>
     27        </div><!-- .panel-image -->
     28
     29    <?php endif; ?>
    1330
    1431    <div class="panel-content">
Note: See TracChangeset for help on using the changeset viewer.