我在本地使用wordpress,出於某種原因,當我從page.php調用getimagesize()來檢索不起作用的大小時。我得到警告: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,正如我在另一個線程中看到的,但無濟於事。圖像正在渲染,所以圖像路徑是正確的,但功能失敗。感謝任何幫助,我可以得到...
您可能沒有啓用打開包裝,因此您無法使用HTTP路徑。你有沒有嘗試給它一個目錄路徑而不是URL? – JohnP
感謝您的快速回復。打開包裝是可用的,是的,我也嘗試了相對路徑。 – gregz