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: https://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: https://jacksonlaycock.com/ */ ?> <?php // borrowed code from https://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='https://twitpic.com/{$match}'><img src='https://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)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Plugin: Twitpic Expander’ is closed to new replies.