twentyfourteen_post_thumbnail

Display an optional post thumbnail.

Description

twentyfourteen_post_thumbnail(); 

Wraps the post thumbnail in an anchor element on index views, or a div element when on single views.


Usage

  1. if ( !function_exists( 'twentyfourteen_post_thumbnail' ) ) { 
  2. require_once '/inc/template-tags.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = twentyfourteen_post_thumbnail(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/inc/template-tags.php  
  1. function twentyfourteen_post_thumbnail() { 
  2. if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { 
  3. return; 
  4.  
  5. if ( is_singular() ) : 
  6. ?> 
  7.  
  8. <div class="post-thumbnail"> 
  9. <?php 
  10. if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) { 
  11. the_post_thumbnail( 'twentyfourteen-full-width' ); 
  12. } else { 
  13. the_post_thumbnail(); 
  14. ?> 
  15. </div> 
  16.  
  17. <?php else : ?> 
  18.  
  19. <a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true"> 
  20. <?php 
  21. if ( ( ! is_active_sidebar( 'sidebar-2' ) || is_page_template( 'page-templates/full-width.php' ) ) ) { 
  22. the_post_thumbnail( 'twentyfourteen-full-width' ); 
  23. } else { 
  24. the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) ); 
  25. ?> 
  26. </a> 
  27.  
  28. <?php endif; // End is_singular()