[wp-trac] [WordPress Trac] #37714: WP 4.6 featured image issue

WordPress Trac noreply at wordpress.org
Thu Aug 18 09:24:29 UTC 2016


#37714: WP 4.6 featured image issue
-----------------------------+------------------------------
 Reporter:  northeme         |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Post Thumbnails  |     Version:  4.6
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+------------------------------

Comment (by northeme):

 Yes, it must be on my end. I've just tried with Twenty Sixteen and
 _thumbnail_id is being added into the div with "inside" class. However,
 somehow it's added outside of inside div on my theme. Apparently I'm
 supposed to investigate this issue.

 Basically what I do is using the code below and remove the default :

 {{{
 remove_meta_box( 'postimagediv','post','side' );
 }}}


 and add my own content with this one :

 {{{
 add_meta_box('postimagediv', $ptitle, 'new_post_thumbnail_meta_box',
 $post_type, 'side', 'low');
 }}}


 Finally I use the function below to call default thumbnail form :

 {{{
 _wp_post_thumbnail_html( $thumbnail_id );
 }}}


 Entire function as follows :

 {{{

 function new_post_thumbnail_meta_box() {
                         global $post, $northeme_customposts,
 $northeme_post_prefs, $northeme_thumbnails; // we know what this does

                         $screen = get_current_screen();

                         echo '<div class="morefields">';

                         if($screen->post_type!='post') {
                                 $opts = array('image'=>'Thumbnail',
 'video'=>'Embed Video URL', 'gif'=>'SVG / Animated Gif');
                         }else{
                                 $opts = array('image'=>'Thumbnail',
 'gif'=>'SVG / Animated Gif');
                         }

                         $args[] = array(
                                                         'type'=>'select',
                                                         'title'=>'Type',
                                                         'name'=>'northeme-
 work-featured-type',
                                                         'desc'=>'',
                                                         'options'=>$opts
                                         );


                         if($screen->post_type!='post') {

                                 $args[] = array(
                                                 'type'=>'tfieldvid',
                                                 'title'=>'Video URL /
 Shortcode',
                                                 'name'=>'northeme-work-
 featured-video',
                                                 'desc'=>'Add a 3rd party
 website URL to display featured video / audio player.<br><br><strong>WP
 oEmbed</strong> function is used for embedding from websites such as
 Youtube, Vimeo, Soundcloud etc. <br><br>Please visit following URL to see
 supported websites :<br><a href=\'http://codex.wordpress.org/Embeds\'
 target=\'_blank\'>http://codex.wordpress.org/Embeds</a><br><br>On the
 other hand, WP video or any video shortcode is accepted : <br> [video
 src=\'http://domain.com/video.mp4\']'
                                         );
                         }

                         $args[] = array(
                                                 'type'=>'upload',
                                                 'title'=>'SVG / Animated
 Gif',
                                                 'name'=>'northeme-work-
 featured-gif',
                                                 'desc'=>'Upload or select
 an animated gif image from media library. SVG / Animated GIF images will
 be displayed in their original size.'
                                         );

                         echo md_create_fields($args,1);


                         if(isset($screen->post_type)) {
 if(isset($northeme_post_prefs[$screen->post_type])) {
                                         $layout_id =
 $northeme_post_prefs[$screen->post_type]['thumbnail'];
                                 }
                         }

                         echo '</div>';

                         $thumbnail_id = get_post_meta( $post->ID,
 '_thumbnail_id', true ); // grabing the thumbnail id of the post
                         echo '<div class="nor-main-thumb-wrap">';
                         echo _wp_post_thumbnail_html( $thumbnail_id ); //
 echoing the html markup for the thumbnail
                         echo '</div>';

                         echo '<div class="hover-thumb">';

                         $args = array(
                                                         array(
 'type'=>'upload',
 'title'=>'Hover Thumbnail (optional)',
                                                                 'name
 '=>'northeme-work-thumb-hover',
 'desc'=>'Show up on image hover'
                                                         )
                                         );

                         echo md_create_fields($args,1);

                         echo '</div>';


                         if(isset($layout_id) &&
 isset($northeme_thumbnails[$layout_id])) {
 if(isset($northeme_thumbnails[$layout_id]['height']) &&
 is_numeric($northeme_thumbnails[$layout_id]['height'])) {

 if($northeme_thumbnails[$layout_id]['width'] > 420) {
                                                 $rec_imgw =
 $northeme_thumbnails[$layout_id]['width'];
                                                 $rec_imgh =
 $northeme_thumbnails[$layout_id]['height'];
                                         }else{
                                                 $rec_imgw = 420;
                                                 $rec_imgh = round(420 /
 ($northeme_thumbnails[$layout_id]['width'] /
 $northeme_thumbnails[$layout_id]['height']));
                                         }

                                         $rec_retina =
 ($rec_imgw*RETINARATIO).'x'.($rec_imgh * RETINARATIO).'px';
                                         $rec_std =
 ($rec_imgw).'x'.($rec_imgh).'px';

                                 }else{

 if($northeme_thumbnails[$layout_id]['width'] > 420) {
                                                 $rec_imgw =
 $northeme_thumbnails[$layout_id]['width'];
                                         }else{
                                                 $rec_imgw = 420;
                                         }

                                         $rec_retina = ($rec_imgw *
 RETINARATIO).'px wide with any height';
                                         $rec_std = ($rec_imgw).'px wide
 with any height';
                                 }

                                 if(RETINARATIO > 1) {
                                         echo '<div class="img-
 explain"><strong>'.$northeme_thumbnails[$layout_id]['name'].'</strong>
 layout requires minimum <strong class="underline">'.$rec_retina.'</strong>
 size images.<br><br>(Retina quality is set as
 <strong>'.RETINARATIO.'x</strong>. Adjust at <a
 href="'.admin_url('admin.php?page=northeme_framework#branding_header').'">Northeme
 > Theme Options > Layout > Website Layout > Retina
 Quality</a>).<br><br>Uploaded images will be cropped automatically unless
 SVG / animated GIF option is not selected.</div>';
                                 }else{
                                         echo '<div class="img-
 explain">Upload minimum <strong>'.$rec_std.'</strong>
 images.<br><br>Uploaded images will be cropped automatically unless SVG /
 animated GIF option is not selected.</div>';

                                 }
                         }

                 }
 }}}

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


More information about the wp-trac mailing list