Post thumbnail problem
-
All my post has external image and my theme did not support post thumnail for external images on home page. now i found one script who show post thumb for external images with hyperlink to the post. but they show the original size of the image, the image did not resize. can anyone tell me what edit i do in the script, so the image will resize according to my choice
This script i add in Functions.php
function getImage($num) {
global $more;
$more = 1;
$link = get_permalink();
$content = get_the_content();
$count = substr_count($content, ‘<img’);
$start = 0;
for($i=1;$i<=$count;$i++) {
$imgBeg = strpos($content, ‘<img’, $start);
$post = substr($content, $imgBeg);
$imgEnd = strpos($post, ‘>’);
$postOutput = substr($post, 0, $imgEnd+1);
$postOutput = preg_replace(‘/width=”([0-9]*)” height=”([0-9]*)”/’, ”,$postOutput);;
$image[$i] = $postOutput;
$start=$imgEnd+1;
}
if(stristr($image[$num],'<img’)) { echo ”.$image[$num].””; }
$more = 0;
}and this added to the Index.php:
<?php getImage(‘1’); ?>
suggest something,
- The topic ‘Post thumbnail problem’ is closed to new replies.