Title: Plugin: Twitpic Expander
Last modified: August 19, 2016

---

# Plugin: Twitpic Expander

 *  [bh](https://wordpress.org/support/users/bh/)
 * (@bh)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/plugin-twitpic-expander/)
 * Hey Guys,
 * I just threw together my first plugin. I am using Twitter Tools to pull in a 
   Twitter feed into WordPress. It was perfect for my needs except for one thing–
   I wanted Twitpic URL’s to display as an image instead of the link URL. I mostly
   borrowed code from different places, but it works. I am posting it here just 
   in case it helps someone. If anyone wants to improve the code I would be super
   grateful! (I am not a programmer, so please excuse any obvious mistakes)
 * Cheers
 *     ```
       <?php
       /*
       Plugin Name: Twitpic Expander
       Plugin URI: http://jacksonlaycock.com/
       Description: Scans posts for twitpic URL's and automatically expands them and shows an image.
       Version: 1.0
       Author: Jackson Laycock
       Author URI: http://jacksonlaycock.com/
       */
       ?>
       <?php
       // borrowed code from http://code.google.com/p/dabr/source/browse/trunk/common/twitter.php?spec=svn116&r=116
   
       function showtwitpic($text){
       	$foo = $text;
       	$tmp = strip_tags($text);
       	// find a mention of twitpic
       	if (preg_match_all('#twitpic.com/([\d\w]+)#', $tmp, $matches, PREG_PATTERN_ORDER) > 0) {
       		foreach ($matches[1] as $match) {
       	     $text = "<a href='http://twitpic.com/{$match}'><img src='http://twitpic.com/show/large/{$match}' class='aligncenter' /></a>";
       	  	}
       		$text = $foo . $text;
       	}	
   
       	return 	$text;
       }		
   
       add_filter('the_content', 'showtwitpic', 21);
       add_filter('the_excerpt', 'showtwitpic', 21);
       ?>
       ```
   

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [alexkingorg](https://wordpress.org/support/users/alexkingorg/)
 * (@alexkingorg)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/plugin-twitpic-expander/#post-1189124)
 * Pretty cool, you should make this a plugin for Twitter Tools so it works in the
   sidebar too.
 *  Thread Starter [bh](https://wordpress.org/support/users/bh/)
 * (@bh)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/plugin-twitpic-expander/#post-1189126)
 * Thanks Alex. I would love to, but I might have to pass the torch on this one.
 * Thanks again for such a great WP/Twitter Plugin!
 *  [vuthy](https://wordpress.org/support/users/vuthy/)
 * (@vuthy)
 * [16 years, 9 months ago](https://wordpress.org/support/topic/plugin-twitpic-expander/#post-1189495)
 * Thanks, this is just what I’m looking for though for some reason, if a post has
   more than one twitpic link, only the last one gets its picture displayed. I’ll
   try to see if I can figure this out.
 * Thanks for the code!
 *  Thread Starter [bh](https://wordpress.org/support/users/bh/)
 * (@bh)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/plugin-twitpic-expander/#post-1189546)
 * Hey Vuthy,
    Did you figure out the code and make any changes?
 *  [smoovej](https://wordpress.org/support/users/smoovej/)
 * (@smoovej)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/plugin-twitpic-expander/#post-1189562)
 * To fix the “more than one twitpic per twit” problem, you just need to concatenate
   the images together with a .= (on the $images = line):
 *     ```
       <?php
       function showtwitpic($text){
         $foo = $text;
         $tmp = strip_tags($text);
   
         // find a mention of twitpic
         if (preg_match_all('#twitpic.com/([\d\w]+)#', $tmp, $matches, PREG_PATTERN_ORDER) > 0) {
           foreach ($matches[1] as $match) {
             $images .= "<a href='http://twitpic.com/{$match}'><img src='http://twitpic.com/show/thumb/{$match}' class='aligncenter' /></a>";
           }
           $text = $foo . '<center>' . $images . '</center>';
         }
   
         return $text;
       }
   
       add_filter('the_content', 'showtwitpic', 21);
       add_filter('the_excerpt', 'showtwitpic', 21);
       ?>
       ```
   
 *  Thread Starter [bh](https://wordpress.org/support/users/bh/)
 * (@bh)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/plugin-twitpic-expander/#post-1189571)
 * Finally got around to adding this to the plugin directory.
 * [http://wordpress.org/extend/plugins/twitpic-expander/](http://wordpress.org/extend/plugins/twitpic-expander/)
 * I also included Smoovej’s change above (thanks!).
 *  [paulstenhouse](https://wordpress.org/support/users/paulstenhouse/)
 * (@paulstenhouse)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/plugin-twitpic-expander/#post-1189576)
 * When this plugin is active, I am getting an error when I try to logout.
 * I get a whole page of errors that look like this:
 * > Warning: Cannot modify header information – headers already sent by (output
   > started at /home/ilovene/public_html/paulstenhouse.com/wp-content/plugins/twitpic-
   > expander/twitpic-expander.php:14) in /home/ilovene/public_html/paulstenhouse.
   > com/wp-login.php on line 302
   > Warning: Cannot modify header information – headers already sent by (output
   > started at /home/ilovene/public_html/paulstenhouse.com/wp-content/plugins/twitpic-
   > expander/twitpic-expander.php:14) in /home/ilovene/public_html/paulstenhouse.
   > com/wp-login.php on line 314
   > Warning: Cannot modify header information – headers already sent by (output
   > started at /home/ilovene/public_html/paulstenhouse.com/wp-content/plugins/twitpic-
   > expander/twitpic-expander.php:14) in /home/ilovene/public_html/paulstenhouse.
   > com/wp-includes/pluggable.php on line 692
   > Warning: Cannot modify header information – headers already sent by (output
   > started at /home/ilovene/public_html/paulstenhouse.com/wp-content/plugins/twitpic-
   > expander/twitpic-expander.php:14) in /home/ilovene/public_html/paulstenhouse.
   > com/wp-includes/pluggable.php on line 693
 * And it means I can’t log out..
 * How can I fix this because it is a great plugin!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Plugin: Twitpic Expander’ is closed to new replies.

## Tags

 * [image](https://wordpress.org/support/topic-tag/image/)
 * [thumbnail](https://wordpress.org/support/topic-tag/thumbnail/)
 * [twitter](https://wordpress.org/support/topic-tag/twitter/)

 * 7 replies
 * 5 participants
 * Last reply from: [paulstenhouse](https://wordpress.org/support/users/paulstenhouse/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/plugin-twitpic-expander/#post-1189576)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
