[wp-trac] [WordPress Trac] #39281: [twentyseventeen] header.php forces thumbnails on all post types

WordPress Trac noreply at wordpress.org
Thu Dec 15 08:47:38 UTC 2016


#39281: [twentyseventeen] header.php forces thumbnails on all post types
---------------------------+------------------------------
 Reporter:  justnorris     |       Owner:
     Type:  defect (bug)   |      Status:  reopened
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Bundled Theme  |     Version:  trunk
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:  ui, template
---------------------------+------------------------------
Changes (by justnorris):

 * status:  closed => reopened
 * resolution:  worksforme =>


Comment:

 Hey @JPry, thanks for the response. However, I have to disagree. My
 custom-post-type does support thumbnails, but I utilize them in a
 different way. Because of the current state of twentyseventeen I can't
 make the plugin compatible with the default WordPress theme. I think every
 WordPress plugin should look and feel great out of the box, with best
 practices intact.

 For my Photography Portfolio plugin - featured images are used in
 archives, but once a gallery is opened - a different set of images are
 used. I don't need to show the featured-image there, so at the moment, I
 have to resort to a hack like this one: https://github.com/justnorris
 /photography-portfolio/commit/d85b14b0232830fbceeb95eac10e5b196d10ae35

 I'd really appreciate it if at least a filter was introduced. I can't be
 the only person on earth doing a custom view for a custom post type.


 In any case - I think the `header.php` readability will too benefit from
 something like this:
 {{{#!php
 <?php
         // If a regular post or page, and not the front page, show the
 featured image.
         if ( twentyseventeen_should_show_featured_image() ) :
                 echo '<div class="single-featured-image-header">';
                 the_post_thumbnail( 'twentyseventeen-featured-image' );
                 echo '</div><!-- .single-featured-image-header -->';
         endif;

         // functions.php
         function twentyseventeen_should_show_featured_image() {
                 return apply_filters(
 'twentyseventeen_should_show_featured_image', ( has_post_thumbnail() && (
 is_single() || ( is_page() && ! twentyseventeen_is_frontpage() ) ) ) );
         }


         ?>

 }}}


 Normally things like thumbnails belong to `single.php`, `archive.php`,
 etc., Twenty Seventeen does things a bit differently, that's alright, as
 long as it doesn't break things for others.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39281#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list