Created
April 11, 2016 20:10
-
-
Save imath/c8dade7480b206118683ef8d1de696ed to your computer and use it in GitHub Desktop.
Use the featured image instead of the user's avatar when listing ideas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Read about how to use the wp-idea-stream-custom.php file here: | |
* https://github.com/imath/wp-idea-stream/wiki/wp-idea-stream-custom.php | |
*/ | |
function pc1271_replace_avatar_with_featured_image( $output, $author, $avatar, $idea ) { | |
if ( ! wp_idea_stream_featured_images_allowed() || ! current_theme_supports( 'post-thumbnails' ) ) { | |
return $output; | |
} | |
/** | |
* the expected size for the avatar is 96x96px, so let's use it there.. | |
*/ | |
$featured_image = get_the_post_thumbnail( $idea, array( 96, 96 ) ); | |
if ( ! empty( $featured_image ) ) { | |
$output = $featured_image; | |
} | |
return $output; | |
} | |
add_filter( 'wp_idea_stream_ideas_get_author_avatar', 'pc1271_replace_avatar_with_featured_image', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment