admin管理员组文章数量:1296276
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;
}
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;
}
Share
Improve this question
asked Jun 27, 2013 at 15:19
user34634user34634
1
3
|
1 Answer
Reset to default 1The 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.
本文标签: imagesSimple Local Avatar Plugin
版权声明:本文标题:images - Simple Local Avatar Plugin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741633432a2389500.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
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 $img_dir = get_bloginfo('template_directory'); $first_img = $img_dir . '/images/post-default.jpg'; } return $first_img;
– user34634 Commented Jun 28, 2013 at 5:57