Currently the code for QuickView's image preview depends on a URL having a known image extension:
if (/^(data\:image)|(\.gif|\.png|\.jpg|\.jpeg|\.svg)$/i.test(tokenString)) {
This is fine in the general case, but falls down when you use an image from a web service. For example, my gravatar image is https://avatars3.githubusercontent.com/u/427398, which will fail this regex and shows no preview, despite the fact that the image can be loaded correctly.
I think this can be improved. Since the preview container is not shown until the preview img element's load event fires, it would be possible to simply try loading a given URL without bothering to check the extension at all. The current code is:
var showHandler = function () {
// Hide the preview container until the image is loaded.
$previewContainer.hide();
$previewContainer.find(".image-preview > img").on("load", function () {
$previewContent
.append("<div class='img-size'>" +
this.naturalWidth + " × " + this.naturalHeight + " " + Strings.UNIT_PIXELS +
"</div>"
);
$previewContainer.show();
positionPreview(editor, popoverState.xpos, popoverState.ytop, popoverState.ybot);
});
};
After setting the img.src to the URL, there are two outcomes: a load or error event. In the load case, the preview would be shown as normal; in the error case, hidePreview() could be called to cancel the pending preview--this is possibly something that should be done anyway, for the case that an image can't be loaded via the URL (e.g., 404).
Would you consider a patch to do this?