Bug 25906 - Need a way to get a preview image/icon from a File object
Summary: Need a way to get a preview image/icon from a File object
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 26221
Blocks:
  Show dependency treegraph
 
Reported: 2009-05-20 20:34 PDT by Eric Seidel (no email)
Modified: 2023-12-11 06:25 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2009-05-20 20:34:40 PDT
Need a way to get a preview image/icon from a File object

This is needed by applications that want to do uploads.  They want to show a preview icon before the upload has actually finished.  <input type="file"> already does something like this.

There are ways to do this in Gears tip of tree source.  In order to get Google applications to move off of this functionality, we need to implement a replacement WebKit. :)  Specifically Google applications are using this functionality to make previews of images before upload.  They don't seem to do so for non-image files.

I don't see anything like this in the FileUpload spec:
http://dev.w3.org/2006/webapi/FileUpload/publish/FileUpload.html
Comment 1 Eric Seidel (no email) 2009-05-21 03:09:34 PDT
Maciej suggested that another way to solve the same problem would be to allow:

imageElement.src = fileObject;

As though dropping a file on a page (thus granting the page permission to use it) would also extend to allowing HTMLImageElements to load such an image and display it.  I think that might even be a slicker solution.  Especially if we expose the mimeType on the File object so you can check first before you do the imageElement.src = fileObject;
Comment 2 Eric Seidel (no email) 2009-06-05 10:48:32 PDT
I think one downside with the HTMLImageElement.src = [object File] option is that the author is not making clear which image they want to show.  Do they want to show an icon?  The preview?  The preview falling back to the icon?  Maybe they want the full contents shown.
Comment 3 Anne van Kesteren 2023-12-11 06:25:20 PST
For a variety of these cases <canvas> or blob: URLs can be used. For the others it would be good to standardize something first.