From e58856bbd081d1af2ad96950f83590b3f6d06c47 Mon Sep 17 00:00:00 2001 From: "David A. Kennedy" Date: Fri, 21 Oct 2016 22:15:50 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@38868 git-svn-id: http://core.svn.wordpress.org/trunk@38811 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../components/header/header-image.php | 9 --------- .../components/page/content-front-page.php | 17 +++++++++++++++++ .../twentyseventeen/inc/template-functions.php | 4 ++-- wp-includes/version.php | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/wp-content/themes/twentyseventeen/components/header/header-image.php b/wp-content/themes/twentyseventeen/components/header/header-image.php index c4437d2be8..102456ddcc 100644 --- a/wp-content/themes/twentyseventeen/components/header/header-image.php +++ b/wp-content/themes/twentyseventeen/components/header/header-image.php @@ -19,15 +19,6 @@
- ID ); - $thumbnail_attributes = wp_get_attachment_image_src( $post_thumbnail_id, 'twentyseventeen-featured-image' ); - ?> - -
- -
diff --git a/wp-content/themes/twentyseventeen/components/page/content-front-page.php b/wp-content/themes/twentyseventeen/components/page/content-front-page.php index cb0ab7d649..38fa0f77e9 100644 --- a/wp-content/themes/twentyseventeen/components/page/content-front-page.php +++ b/wp-content/themes/twentyseventeen/components/page/content-front-page.php @@ -11,6 +11,23 @@ ?>
> + ID ), 'twentyseventeen-featured-image' ); + + $post_thumbnail_id = get_post_thumbnail_id( $post->ID ); + + $thumbnail_attributes = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'twentyseventeen-featured-image' ); + + // Calculate aspect ratio: h / w * 100%. + $ratio = $thumbnail_attributes[2] / $thumbnail_attributes[1] * 100; + ?> + +
+
+
+ + +
diff --git a/wp-content/themes/twentyseventeen/inc/template-functions.php b/wp-content/themes/twentyseventeen/inc/template-functions.php index 8e6da7992a..5ea106b70b 100644 --- a/wp-content/themes/twentyseventeen/inc/template-functions.php +++ b/wp-content/themes/twentyseventeen/inc/template-functions.php @@ -34,8 +34,8 @@ function twentyseventeen_body_classes( $classes ) { $classes[] = 'twentyseventeen-front-page'; } - // Add a class if there is a featured image or custom header. - if ( has_header_image() || ( has_post_thumbnail() && twentyseventeen_is_frontpage() ) ) { + // Add a class if there is a custom header. + if ( has_header_image() ) { $classes[] = 'has-header-image'; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 051e2c1064..5499bc5d09 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-alpha-38867'; +$wp_version = '4.7-alpha-38868'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.