I am trying to load an image from file using Javascript LoadImage library (https://github.com/blueimp/JavaScript-Load-Image).
The load method returns me an image object with its src
set to some blob object:
<img src="blob:http%3A//localhost%3A3577/902d4e78-2e3e-467c-99ce-6683db24996e" width="960" height="540">
If I append this element to DOM, it's displayed nicely. However, for my need, I just need the image data, not the DOM object. I need to take that data and set another, existing element's src
to that. So, just like any sane person would do, I get the returned object's src
(blob:http%3A//localhost%3A3577/902d4e78-2e3e-467c-99ce-6683db24996e
), get a reference to my existing image DOM object (named img
below), and using jQuery, set its src:
img.attr('src', src);
This results in my existing image object becoming:
<img src="blob:http%3A//localhost%3A3577/902d4e78-2e3e-467c-99ce-6683db24996e">
.
Yes, exactly the same (expect explicit width
and height
attributes, which I also tried to add, which changed absolutely nothing). But instead of the image, my existing tag now displays a broken image:
Why and how when image tags with the same src
, one can display the image and the other cannot?