我在我的博客(getImage)中使用一个函数来调用循环中的缩略图(它调用文章中的第一个图像),但我希望缩略图链接到其完整的图像src,而不是链接到文章。
功能如下:
function getImages($num) {
global $more;
$more = 1;
$link = get_permalink(); -> NO IDEA IF HAS ANY SENSE BUT I ALREADY TRIED TO CHANGE THIS ONE TO GET_ATTACHMENT BUT NO LUCK
$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]*)"/\', \'/width="150"/\',$postOutput);
$postOutput = preg_replace(\'/alignright/\', \'aligncenter\',$postOutput);
$image[$i] = $postOutput;
}
if(stristr($image[$num],\'<img\')) { echo \'<a href="\'.$link.\'">\'.$image[$num]."</a>"; }
$more = 0;}
有人知道我该怎么做吗?或其他功能来实现这一点?谢谢