W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2012

Re: [FileAPI] createObjectURL isReusable proposal

From: Glenn Maynard <glenn@zewt.org>
Date: Mon, 30 Jan 2012 09:14:06 -0600
Message-ID: <CABirCh8CNAhtzKKpDvaB3=uyc-g6HJJA1Rp0=QYGC+5WcEe5tg@mail.gmail.com>
To: Bronislav Klučka <Bronislav.Klucka@bauglir.com>
Cc: public-webapps@w3.org
2012/1/30 Bronislav Klučka <Bronislav.Klucka@bauglir.com>

> And how? Using src attribute? that would have to be changed to accept both
> string and Blob object? What it would return on get operation? Libraries
> managing images (lightboxes) would have to consider, what does src mean? Or
> do you propose other attribute? What would then be in src?

img1 = document.getElementById("my-image");
img1.src = myBlob;
assert(img1.src == myBlob);
img2 = document.getElementById("my-other-image");
img2.src = img1.src; // works as always; you can't do this with
auto-releasing object URLs

This is trivially simple for users to understand, and doesn't raise any of
the hard issues that auto-releasing object URLs do.

The main question is innerHTML/outerHTML, where the object can't be
represented; it would need to be exposed as a placeholder string.
 (However, auto-release object URLs break many uses of these too, since the
URL is no longer valid!)  It means you can't use this with most approaches
to HTML templating in JS, which is annoying.  That said, there have been
various suggestions for augmenting HTML-like templating, and it could be
made possible, eg.:

document.createTemplatedElement("<img width=${width} height=${height}
src=${myImage}>", {myImage: myBlob, width: 800, height: 600});

What if I change that blob? Should image change immediately as well? What
> if this was video playing?

You can't change a blob.

Glenn Maynard
Received on Monday, 30 January 2012 15:14:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:31 UTC