Twenty Fourteen: add full-width featured images for layouts without a content sidebar, but use wp_is_mobile()
to load smaller-sized images for mobile. Props iamtakashi, fixes #25758.
git-svn-id: https://develop.svn.wordpress.org/trunk@26026 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
370c503d66
commit
8b481f300b
@ -69,6 +69,7 @@ function twentyfourteen_setup() {
|
||||
|
||||
// Add several sizes for Post Thumbnails.
|
||||
add_image_size( 'post-thumbnail-slider', 1038, 576, true );
|
||||
add_image_size( 'post-thumbnail-full-width', 1038, 0 );
|
||||
add_image_size( 'post-thumbnail-grid', 672, 372, true );
|
||||
add_image_size( 'post-thumbnail', 672, 0 );
|
||||
|
||||
|
@ -172,14 +172,21 @@ function twentyfourteen_post_thumbnail() {
|
||||
?>
|
||||
|
||||
<div class="post-thumbnail">
|
||||
<?php the_post_thumbnail( 'post-thumbnail' ); ?>
|
||||
<?php
|
||||
if ( is_active_sidebar( 'sidebar-2' ) || wp_is_mobile() )
|
||||
the_post_thumbnail( 'post-thumbnail' );
|
||||
else
|
||||
the_post_thumbnail( 'post-thumbnail-full-width' );
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<a class="post-thumbnail" href="<?php the_permalink(); ?>" rel="<?php the_ID(); ?>">
|
||||
<?php if ( has_post_thumbnail() ) :
|
||||
<?php if ( has_post_thumbnail() && ( is_active_sidebar( 'sidebar-2' ) || wp_is_mobile() ) ) :
|
||||
the_post_thumbnail( 'post-thumbnail' );
|
||||
elseif ( has_post_thumbnail() ) :
|
||||
the_post_thumbnail( 'post-thumbnail-full-width' );
|
||||
else : ?>
|
||||
<p class="screen-reader-text"><?php _e( 'No featured image.', 'twentyfourteen' ); ?></p>
|
||||
<?php endif; ?>
|
||||
|
Loading…
Reference in New Issue
Block a user