WordPress Development Asked by user34634 on December 19, 2021
I think that Im very close to achieve my goal..
I have this function on my themes but I need a help to find the right way to call simple local avatar function so it will show the local avatar image from simple local avatar pugin instead wordpress gravatar?
$first_img = get_avatar( $post->post_author );
Is there anyone can help?
function get_post_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=['"]([^'"]+)['"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = get_avatar( $post->post_author );
}
return $first_img;
}
The get_avatar
function is pluggable, meaning that you can define a function of your own having that name and completely overwrite the default function.
If you look at the source for the "Simple Local Avatars" plugin, that is exactly what it has done. get_avatar
in your code should be using the function defined by "Simple Local Avatars".
"Simple Local Avatars" provides a simplified function, get_simple_local_avatar
, that you can use instead if you want.
Answered by s_ha_dum on December 19, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP