New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library fails if the URL of image is redirected (i.e. http to https) #51
Comments
An addition: It seems that @file_get_contents can't follow redirections if the redirection is a meta or JavaScript redirection. This debug code opens a new window with the image, the browser executes the JavaScript.
I haven't the PHP experience to solve this problem, because the JavaScript must be executed to get the real url of image. There are no fixed string within the JavaScript code (like window.location), the url generation is dynamic. So I think the library is not useful if the image link redirects using meta or JavaScript redirection. |
To be honest, this library was never meant as a library that can and should handle all the possible pitfalls of redirects. You should make sure that data passed to this library is a valid image path and/or handle the possibility of this not being the case. Similar issues should also apply to the PHP native getimagesize function which IMHO uses the same core functionality that I am using with file_get_contents. |
I am not the developer of this forum software. I was only a user there and have had this problem as much others. I think a possible fix must be done by the forum software developers. So I close this here. Thanks! |
Could it be, that the function @file_get_contents has a problem with some redirected links?
That's a problem in phpBB, if a link to an image is redirected from http to https. The server answers with a 301 or 302, i.e. permanently redirected and after this the image data are transfered.
In this example https://www.stummiforum.de/viewtopic.php?f=14&t=161634&start=25#p1899025 the image link is redirected to https if you call it with http. This server strangely answers first with "Please enable Javascript".
The result of @file_get_contents are the first answer of the server, which isn't the image. So the library tries to find a image size in this data which results in an error:
"It was not possible to determine the dimensions of the image. Please verify that the URL you entered is correct."
I think, there is a javascript for redirect and @file_get_contents get this script result and not an image.
Can this problem be confirmed?
The text was updated successfully, but these errors were encountered: