WordPress.org

Make WordPress Core

Ticket #18804: postthumb.18804.1.patch

File postthumb.18804.1.patch, 1.2 KB (added by danielbachhuber, 3 years ago)

Include 'has-featured-image' as a class if the post does and theme supports it

  • wp-includes/post-template.php

     
    301301/** 
    302302 * Retrieve the classes for the post div as an array. 
    303303 * 
    304  * The class names are add are many. If the post is a sticky, then the 'sticky' 
    305  * class name. The class 'hentry' is always added to each post. For each 
     304 * The class names are many. If the post is a sticky, then the 'sticky' 
     305 * class name. The class 'hentry' is always added to each post. If the post has a 
     306 * featured image, 'has-featured-image' is added as a class. For each 
    306307 * category, the class will be added with 'category-' with category slug is 
    307308 * added. The tags are the same way as the categories with 'tag-' before the tag 
    308309 * slug. All classes are passed through the filter, 'post_class' with the list 
     
    337338                else 
    338339                        $classes[] = 'format-standard'; 
    339340        } 
     341         
     342        // Post Thumbnail, but we need to check for theme support before we call the function 
     343        if ( current_theme_supports( 'post-thumbnails' ) ) 
     344                if ( has_post_thumbnail( $post->ID ) ) 
     345                        $classes[] = 'has-featured-image'; 
    340346 
    341347        // post requires password 
    342348        if ( post_password_required($post->ID) )