bugFix for Thumbnail image issue
-
Hi again ??
As plugin users are having problem setting thumbnails because this plugin is overriding the post thumbnail. I have wrote a fix for this.
This fix sets featured image in following condition
1. When thumbnail is enabled.
2. When post doesn’t already have a thumbnail. This fixes issue lots of people having.# Fix
class-categoryfeaturedimage.php
/** ================================================== * Update thumbnail meta data of a post to category thumbnail. * Only updates if post doesn't have a thumbnail image set by user. * * @param int $post_id post_id. * @since 2.00 */ public function update_thumbnail( $post_id ) { // Skip if current theme doesn't support post thumbnails if ( ! current_theme_supports( 'post-thumbnails' ) ) { return; } // Skip post thumbnail update if thumbnail is already set in the post if ( has_post_thumbnail( $post_id ) ) { return; } $term_id = $this->choose_term( $post_id ); if ( 0 < $term_id ) { $featured_image_id = intval( get_term_meta( $term_id, 'featured_image_id', true ) ); update_post_meta( $post_id, '_thumbnail_id', $featured_image_id ); } else { delete_post_meta( $post_id, '_thumbnail_id' ); } }
Here is a gist url for your continence!
https://gist.github.com/prionkor/5207a953fbc9590acf104431f74719e2I have tested it but please test yourself as well. Let me know if you have any comments.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘bugFix for Thumbnail image issue’ is closed to new replies.