Skip to content

Instantly share code, notes, and snippets.

@sofish
Created March 4, 2012 16:18
Show Gist options
  • Select an option

  • Save sofish/1973727 to your computer and use it in GitHub Desktop.

Select an option

Save sofish/1973727 to your computer and use it in GitHub Desktop.
appinn
<div class="thumbnail">
<a href="<?php the_permalink(); ?>">
<?php
$soContent = $post->post_content;
$soImages = '~<img [^\>]*\ />~';
preg_match_all($soImages, $soContent, $thePics );
$allPics = count($thePics[0]);
if($allPics > 0 ){
$img_url = $thePics[0][0];
preg_match('~img3~', $img_url, $isImg3);
if($isImg3){
$img_pos = strrpos($img_url, '/') + 1;
$img_url_prefix = substr($img_url, 0, $img_pos);
$img_url_midfix = 'thumbs/thumbs_';
$img_url_subfix = substr($img_url, $img_pos);
echo $img_url_prefix . $img_url_midfix . $img_url_subfix;
} else {
echo $img_url;
}
} else {
echo '<img src="http://www.appinn.com/wp-content/themes/appinn/images/no.jpg" alt="NO" />';
} ?>
</a>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment