drewbrolik / Responsive-Img

Responsive Img is a jQuery plugin that changes an image's src attribute based on its container's width.
207 stars 36 forks source link

404 / Failed to open stream #9

Open stefanschleich opened 10 years ago

stefanschleich commented 10 years ago

I just tried your script and got an error in the console:

GET http://www.mydomain.de/dee/responsive/img/1500x500_large.jpg 404 (Not Found) responsiveImg.js:170
XHR finished loading: "http://www.mydomain.de/dee/responsive/js/responsiveImg.js.php?makeImage=1&file…mg%2F1500x500.jpg&fileOut=img%2F1500x500_large.jpg&size=900&jpegQuality=90". jquery.js:8706

Calling the PHP-file from the message above shows an error stating the image could not be found. The path used by getimagesize looks pretty messed up too.

Warning: getimagesize(../../../../www.mydomain.deimg/1500x500.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /var/www/web199/html/dee/responsive/js/responsiveImg.js.php on line 153
0 target width is 900 and original width is

Heres my img-tag:

<img src="img/1500x500.jpg" alt="">

Opening the image directly in the browser works fine.

I already tried to put an absolute URL to the image in the img-tag but this won't work either.

drewbrolik commented 10 years ago

Hello,

The first time Responsive Img needs to create an image, it throws that "not found" error, but then it creates the image. In your case, though, that path does look crazy.

Do you specify a different "pathToPHP" value when you call the plugin?

Drew

Drew Thomas CCO Brolik Productions thomasa@brolik.com thomasa@webrolik.com 267 297 8421 x203 brolik.com brolik.com/drewthomas

On Tue, Jan 7, 2014 at 5:04 AM, stefanschleich notifications@github.comwrote:

I just tried your script and got an error in the console:

GET http://www.mydomain.de/dee/responsive/img/1500x500_large.jpg 404 (Not Found) responsiveImg.js:170 XHR finished loading: "http://www.mydomain.de/dee/responsive/js/responsiveImg.js.php?makeImage=1&file…mg%2F1500x500.jpg&fileOut=img%2F1500x500_large.jpg&size=900&jpegQuality=90". jquery.js:8706

Calling the PHP-file from the message above shows an error stating the image could not be found. The path used by getimagesize looks pretty messed up too.

Warning: getimagesize(../../../../www.mydomain.deimg/1500x500.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /var/www/web199/html/dee/responsive/js/responsiveImg.js.php on line 153 0 target width is 900 and original width is

Heres my img-tag:

Opening the image directly in the browser works fine.

I already tried to put an absolute URL to the image in the img-tag but this won't work either.

— Reply to this email directly or view it on GitHubhttps://github.com/drewbrolik/Responsive-Img/issues/9 .

marc7000 commented 9 years ago

Hi Drew,

thanks for this great plugin! I just tried your script and got the same error, before a new image is created, like stefanschleich.

Warning: getimagesize(../../../../../responsive-image.localimg/slide1.jpg): failed to open stream: No such file or directory in /Volumes/Workspace SSD/Webserver/responsive-image/js/vendor/responsiveImg/js/responsiveImg.js.php on line 153

I have a simple fix, adding a slash before the image source.

<div class="image-wrapper">
    <img src="/img/slide1.jpg" />
</div>

Otherwise add a "DIRECTORY_SEPARATOR" between $baseURL and $_REQUEST['fileIn'] / $_REQUEST['fileOut']

Line 147: $fileIn = getRelativePath($self, $baseURL .DIRECTORY_SEPARATOR. $_REQUEST['fileIn']);
Line 148: $fileOut = getRelativePath($self, $baseURL .DIRECTORY_SEPARATOR. $_REQUEST['fileOut']);

Marc

drewbrolik commented 9 years ago

That's great! Thanks for the info.