Support » Plugin: People Lists » [Plugin: People Lists] use author thumbnail in individual posts?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor sgagan

    (@sgagan)

    Hey smemon,

    Glad to here it has helped and I had the same headache a couple months ago, which is why I threw this guy together and hosted it here for all of you! You can only lists into pages/posts. That being said, create a list that is called “one photo example”. Now, select the user photo that you’d like to display and modify the template info to ONLY use the %thumbnail%. And… you’re done! 😛

    Throw in a div and/or some CSS to style the photo as you wish and grab the shortcode from that list and insert it in a post for the image to display. The beauty of this is that you can throw multiple users onto a list and style their photos to display as you wish, without having to display any of their other content.

    The possibilities are truly endless! Good luck and thank you for your feedback,

    Gagan.

    Thread Starter smemon

    (@smemon)

    Thanks Gagan not quite the solution i was looking for though, allow me to explain my problem a bit better…

    Lets say i have 100 posts by 100 different authors and i want to place the authors avatar after every post they make.

    Within a theme template file i.e. single.php, how can i call the author’s avatar? Or is that currently possible?

    Many Thanks!

    Plugin Contributor sgagan

    (@sgagan)

    Hey smemon,

    This is not possible with this plugin, since it works in coordination with User Avatar (http://wordpress.org/extend/plugins/user-avatar/) that is simply for providing the image to be used as a code in the template info area as you know.

    However, for your requirement, try using the get_avatar function because we are replacing that avatar with the uploaded user avatar. From there, just get the current user’s ID, get their respective avatar using the function and throw it where you need it. Sorry I can’t be more specific, but this should give you some insight on how to go about doing things.

    Hope this helps,

    Gagan.

    Thread Starter smemon

    (@smemon)

    Hi Gagan,

    Thanks for your help 🙂 i’ve tried get_avatar and had a look at it in wp-includes/pluggable.php but it’s a bit over my head to be honest!

    I know that in theory it sounds simple… but it’s not as easy as i thought! Anyway, thanks for your help and keep up the good work!

    Sean.

    Thread Starter smemon

    (@smemon)

    Hi Gagan,

    Just an update; i like your plugin so much (but i really needed to display author info in posts) so i spent literally ALL DAY yesterday working on this problem…

    So for you and anyone else who may want to enhance this plugin, here’s some php code which you can insert inside the loop (e.g. in template files) which will retrieve the user’s thumbnail image which has been created by the user-avatar plugin..

    <?php
    $userid = get_the_author_ID();
    $findimages = glob('path-to-site/wp-content/uploads/avatars/'.$userid.'/*-bpfull.jpg');
    $string = $findimages[0]; // Pick one image.
    // Now delete the parts of the path before the site root.
    $pattern = "@path-to-site@";
    $replacement = "";
    $newString = preg_replace($pattern, $replacement, $string);
    echo '<img src="'.$newString.'" />';
    ?>

    I finally got this working at about 3am last night having spent all day working on it 🙂

    Thread Starter smemon

    (@smemon)

    And just to make it a bit friendlier, here’s an updated version which displays nothing if the user hasn’t uploaded an image;

    <?php
    $userid = get_the_author_ID();
    $findimages = glob('path-to-site/wp-content/uploads/avatars/'.$userid.'/*-bpfull.jpg');
    $string = $findimages[0]; // Pick one image.
    // Now delete the parts of the path before the site root.
    $pattern = "@path-to-site@";
    $replacement = "";
    $newString = preg_replace($pattern, $replacement, $string);
    if ($string != ""){
    echo '<img src="'.$newString.'" />';
    }
    ?>
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: People Lists] use author thumbnail in individual posts?’ is closed to new replies.