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...

2
  • 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? Commented Dec 8, 2011 at 12:48
  • Thanks for the quick reply. The fopen wrappers are enbabled and yes I have tried a relative path as well. Commented Dec 8, 2011 at 13:21

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the quick reply. Yeah, I tried using a relative path before and still could not get it to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.