-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Allow QuickView image preview for arbitrary URLs missing image known extension #10786
Comments
Something like this: humphd@542cd1d |
@humphd Great idea, but a little feedback from my side: Thus, I'd suggest two things, maybe do both, maybe just of them:
|
Browsers already do the optimization you suggest per the HTML spec. Specifically, if an Adding a black-list of extensions to ignore (html, json, css, ...), which are specifically known to not yield useful previews would probably be good. I'll add that to my patch. |
I suggested to do a HEAD request first so the browser doesn't need to download the whole file. |
My PR is updated. Also, I confirmed that Firefox does in fact do what I said above, namely, if you try to use a 50M JSON file as the |
I wouldn't call Chrome's behavior a bug -- usually, HTML is used on normal webpages, where an |
Fix #10786 - Allow QuickView image preview for arbitrary URLs
Currently the code for QuickView's image preview depends on a URL having a known image extension:
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'sload
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:After setting the
img.src
to the URL, there are two outcomes: aload
orerror
event. In theload
case, the preview would be shown as normal; in theerror
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?
The text was updated successfully, but these errors were encountered: