Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One problem with the extension is that a URL that looks like this: https://domain.com/download?id=123 doesn't have a file extension. The thumbnailer still works fine if this is the case (as long as the thumb is used in an
<img>
tag), but in many default setups the image will bear the content-type "application/octet-stream". If this image is linked to, it will download rather than showing in the browser window by default. This causes it to fail, for example, when used with GLightBox.This PR adds a dependency, which is needed because Yii2's FileHelper::getExtensionsByMimeType returns silly answers for common MIMEs. For example, Yii2's answer to "image/jpeg" is ".jfif". By default, httpd will serve .jfif as application/octet-stream.
The MIME type is determined either using FileHelper::getMimeType() which fails for URLs, or using get_headers() to fetch the Content-Type of the remote image.
I also added Inflector::slug to correct unusual characters in the filename which caused problems with file retrieval, and hashed the querystring. This just makes the generated names a little more sane and removes characters like "&", "?", and "=".