The MU forums have moved to WordPress.org

[closed] combine avatars and sitewide latest posts (11 posts)

  1. demonicume
    Member
    Posted 16 years ago #

    i'm using this plugin to display recent posts. i'm trying to modify it to display site avatars. looking at the plugin, it already has a function to display avatars
    'if ( function_exists('show_author_thumb') ) :
    $profilepic = show_author_thumb($thispost[0]->post_author , 32);
    echo $profilepic;
    endif;'

    i was able to display my default avatar by cobbling in stuff from the avatar plugin, specifically:

    'function author_image_tag($authorID, $tags = '', $display = true) {
    $path = author_image_path($authorID, false, 'absolute');
    $width = author_image_dimensions($path, 'width');
    //$height = author_image_dimensions($path, 'height');//again not needed
    $tag = '<img src="' . author_image_path($authorID, false, 'url') . '" width=' . $width . ' '. $tags . ' ' . ' id="authorpic" />';
    if ($display) { echo $tag; } else { return $tag; }
    }'

    any ideas on to make this pull the appropriate avatar? my end goal would be to display latest posts with avatars. any ideas would be appreciated.

  2. andrea_r
    Moderator
    Posted 16 years ago #

    Ahhhhh.. I see what you did there... :D the author refers to the authors *on that blog*. gotta pull the *user's* ID that is attached to that particular post.

    And you know the format is user_id.jpg in the avatar directory, right? :)

  3. demonicume
    Member
    Posted 16 years ago #

    i dont have it yet, but i'm gonna crack a beer and stare at it for a few hours. thank you very much, lady.

    Curt

  4. suleiman
    Member
    Posted 16 years ago #

    demonicume, try this code on your site and let me know if it works or not. It's actually xiando's code so if it doesn't work I may not be able to help resolve the issue, but here goes:

    <!-- begin Bloglist /-->
    <li class="sidebox">
    <?php
    $blogs = get_last_updated(10);
    if( is_array( $blogs ) ) {
            ?>
            <h2>Bloggers</h2>
    
    <ul>
            <?php
    
            global $wpmuBaseTablePrefix, $wpdb;
    
            foreach( $blogs as $details ) {
    
            $blogownerid = $wpdb->get_var("SELECT post_author FROM " . $wpmuBaseTablePrefix . $details[ 'blog_id' ]. "_posts");
    
    if ( function_exists('show_author_thumb') ) :
            $profilepic = show_author_thumb($blogownerid, 32);
    endif;
            echo '
    <li>' . $profilepic . '<a href="http://' . $details[ 'domain' ] . $details[ 'path' ]
            . '">' . get_blog_option( $details[ 'blog_id' ], 'blogname' ) . '</a></li>
    ';
            } ?>
            </ul>
    <?php } ?>
    
    </li>
    <!-- end Bloglist /-->
  5. suleiman
    Member
    Posted 16 years ago #

    remember too that you need to be using the latest version of the avatar plugin (as that one generates the different sized avatars)

  6. andrea_r
    Moderator
    Posted 16 years ago #

    Ack! Backticks, suleiman! the page is all messed up. :D

  7. demonicume
    Member
    Posted 16 years ago #

    did the forum eat some of the code?

  8. andrea_r
    Moderator
    Posted 16 years ago #

    I think it's more the code had an unclosed div.

  9. demonicume
    Member
    Posted 16 years ago #

    looks like something is missing though. right around he ' '. $profilepic' part. maybe its a linebreak.

    thanks for the help Sul, it didn't work, but its given me some ideas

  10. Iron
    Member
    Posted 16 years ago #

    funny to see such bug

  11. suleiman
    Member
    Posted 16 years ago #

    sorry for that folks, here is the code in backticks :)

    [Removed to save the forum :) - Mark]

About this Topic

  • Started 16 years ago by demonicume
  • Latest reply from suleiman