我在本地使用wordpress,由于某种原因,当我从page.php调用getimagesize()来检索它不能工作的大小时。我得到了警告:
getimagesize(http://localhost:8080/wordpress/wp-content/themes/minimize/_/images/img-2.jpg )
[function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.0 404
Not Found in C:\wamp\www\wordpress\wp-content\themes\minimize\page.php on line 13调用它的实际代码是:
$items = get_post_meta($post->ID, 'test');
foreach($items as $item) {
$img_pth = 'http://localhost:8080/wordpress/wp-content/themes/HTML5-Reset-Wordpress-Theme/_/images/'.$item;
list($width, $height) = getimagesize($img_pth);
echo '<img src="'.$img_pth.'" height="'.$height.'" width="'.$width.'">';
}我刚开始使用PHP,所以如果我的代码中有一些非常明显的东西,我不会感到惊讶,但我认为我想要做的是非常简单和直接的。我尝试将localhost更改为127.0.0.1,就像我在另一个线程中看到的那样,但无济于事。正在渲染图像,因此图像路径是正确的,但函数失败。谢谢你能帮我的忙。
发布于 2011-12-08 20:49:20
我也有同样的问题。
请改用文件的相对路径。
发布于 2014-10-30 08:12:36
https://stackoverflow.com/questions/8431190
复制相似问题