2

I'm working with wordpress locally and for some reason when I call getimagesize() from page.php to retrieve the sizes it does not work. I get the warning:

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

The actual code that is calling it is:

$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.'">';

        }

I'm new to working with PHP so I wouldn't be surprised if it is something very obvious with my code, but I think what I'm trying to do is pretty easy and straight forward. I've tried changing localhost to 127.0.0.1 as I saw in another thread but to no avail. The images are being rendered, so the image paths are correct, but the function is failing. Thanks for any help I can get...

JohnP
  • 49,507
  • 13
  • 108
  • 140
gregz
  • 45
  • 1
  • 5
  • you might not have fopen wrappers enabled so you can't use the HTTP path. Have you tried giving it a directory path instead of a URL? – JohnP Dec 08 '11 at 12:48
  • Thanks for the quick reply. The fopen wrappers are enbabled and yes I have tried a relative path as well. – gregz Dec 08 '11 at 13:21

2 Answers2

3

I had the same problem.
Use relative path to the file instead.

Awais Qarni
  • 17,492
  • 24
  • 75
  • 137
lvil
  • 4,326
  • 9
  • 48
  • 76
  • Thanks for the quick reply. Yeah, I tried using a relative path before and still could not get it to work. – gregz Dec 08 '11 at 13:20
0

You are using wordpress, so it's probably one of two:

  1. php configuration (php.ini)
  2. one of the plugins you're using

Please see my full answer at this link

Community
  • 1
  • 1
AlonMichaeli
  • 161
  • 1
  • 7