wordpress | January 26th, 2010

Add this function to function.php file

function getImage($num) {
global $more;
$more = 1;
$link = get_permalink();
$content = get_the_content();
$count = substr_count($content, ‘
$start = 0;
for($i=1;$i<=$count;$i++) {
$imgBeg = strpos($content, ”);
$postOutput = substr($post, 0, $imgEnd+1);
$postOutput = preg_replace(‘/width=”([0-9]*)” height=”([0-9]*)”/’, ‘/width=”117″ height=”68″/’,$postOutput);
$postOutput = preg_replace(‘/alignright/’, ‘alignleft’,$postOutput);

$image[$i] = $postOutput;
$start=$imgEnd+1;
}
if(stristr($image[$num],’‘.$image[$num].”“; }
$more = 0;
}

and call it as where you want to show image <?php getImage(‘1′); ?>  .. inside loop.

There are no comments yet, add one below.

Leave a Comment


You must be logged in to post a comment.