嘿,我是一个WP noob,但我的任务是从3.2升级WP。x至3.5。x、 现在一些图像没有显示。
下面是负责它的代码块:
$query = "select w1.guid,w2.post_title, w1.ID from wp_posts w1,wp_posts w2 where w2.id=w1.post_parent and w1.post_type=\'attachment\' and w1.post_parent in (".$post_a.") and w2.post_status=\'publish\' ORDER BY w2.post_date DESC ".$lim_." ";
$terms = $wpdb->get_results($query);
print_r($terms); // for debugging
for ($i = 0; $i < sizeof($terms); $i++) {
$gallery_image_thumb = wp_get_attachment_image_src($terms[$i]->ID, \'thumbnail\');
if ($size != "") {
$result_[$i] = \'<img src="\'.$gallery_image_thumb[0].\'" alt="\'.$terms[$i]->post_title.\'" border="3"> \';
} else {
$result_[$i] = \'<img src="\'.$gallery_image_thumb[0].\'" alt="\'.$terms[$i]->post_title.\'" border="0">\';
}
因此,对于一个部分,它正确地显示图像,但对于另一个部分,它生成的图像为空src
s所以我打印了$terms
搜索结果数组,这是适用于该部分的内容:
Array ( [0] => stdClass Object ( [guid] => http://www.mysite.com/wp-content/uploads/2013/05/jmc-body.jpg [post_title] => jmc-body [ID] => 28358 ) [1] => stdClass Object ( [guid] => http://www.mysite.com/wp-content/uploads/2013/05/jmc-80.jpg [post_title] => jmc-80 [ID] => 28356 )
$terms
无效节的数组:Array ( [0] => stdClass Object ( [guid] => http://www.mysite.com/images/mysite/gallery_latest_images/ckc721.jpg [post_title] => CKC_704 [ID] => 25367 ) [1] => stdClass Object ( [guid] => http://www.mysite.com/images/mysite/gallery_latest_images/jmc1294toy.jpg [post_title] => JMC_1294 [ID] => 25366 )
wp_get_attachment_image_src
仅在上载中查看?有人知道一个干净的方法来解决这个问题吗?我不确定我能做什么样的“如果/否则”陈述。。。除非它是用于匹配guid的正则表达式?