• Resolved privatejoker86

    (@privatejoker86)


    I’m using to this to produce a feed by username. I was hoping that I would be able to show the image/avatar associated with the tweet (such as original image in the case of a retweet).

    If this is not a feature that I’m missing, are you able to perhaps provide some vague direction? I believe I could take it from there.

    Thank you very much for reading and taking the time to respond.

    http://wordpress.org/extend/plugins/twitter-widget-pro/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Aaron D. Campbell

    (@aaroncampbell)

    You could use the “widget_twitter_content” filter to modify the tweet text to include the avatar of the person that tweeted it. The actual tweet info from Twitter is supplied as the second argument to that filter, and I think that would have everything you need in it.

    Thread Starter privatejoker86

    (@privatejoker86)

    Thanks for taking the time to reply. That ended up sending me down the path I used. For anyone trying to do what I did, here’s my solution:

    Inside the loop (around line 640):

    foreach ( $tweets as $tweet ) {

    I added:

    if ($tweet->retweeted_status->user->profile_image_url == "") {
    						$widgetContent .= "<span class='entry-image'><img src='".$tweet->user->profile_image_url."' /></span>";
    				} else {
    						$widgetContent .= "<span class='entry-image'><img src='".$tweet->retweeted_status->user->profile_image_url."' /></span>";
    
    				}

    Plugin Author Aaron D. Campbell

    (@aaroncampbell)

    The problem with doing it that way is that the next time I release an update to the plugin you’ll have to edit it again (and then again and again as the plugin continues to receive updates). Instead try this:

    function range_widget_twitter_content( $content, $tweet ) {
    	$image_link = '<a href="http://twitter.com/%1$s"><span class="entry-image"><img src="%2$s" /></span></a>%3$s';
    	if ( empty( $tweet->retweeted_status ) )
    		$content = sprintf( $image_link, $tweet->user->screen_name, $tweet->user->profile_image_url, $content );
    	else
    		$content = sprintf( $image_link, $tweet->retweeted_status->user->screen_name, $tweet->retweeted_status->user->profile_image_url, $tweet->retweeted_status->text );
    
    	return $content;
    }
    add_filter( 'widget_twitter_content', 'range_widget_twitter_content', null, 2 );

    That will add the profile image to each tweet, link that profile image to the correct user account on Twitter, and also replace the content with the original tweet content if it’s a retweet.

    Plugin Author Aaron D. Campbell

    (@aaroncampbell)

    Oh, that code should go in another plugin or in your theme’s functions.php file.

    Thread Starter privatejoker86

    (@privatejoker86)

    Thank you so much for both the great plug-in and the time to help. This is working great in my functions.php file.

    I’m still trying to figure out how all these filters add content without clobbering each other, but that’s just my newness to WP’s plug in framework I think.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Twitter Widget Pro] Make image/avatar show up?’ is closed to new replies.