I use the picturec element sourceto choose which image to upload. And although I can add a listener load, I can’t understand which image was loaded as an attribute img src srcand property as empty, even if they were loaded!
picture
source
load
img
src
<picture> <source srcset="images/test1.png" media="(min-width: 64em)"> <source srcset="images/test2.png" media="(max-width: 63.99em)"> <!-- This will alert an empty string "" --> <img srcset="images/test.png" alt="" onload="alert( this.src );"> </picture>
How to determine which image was uploaded?
, , : currentSrc. image.onload . src.
currentSrc
img.onload = function() { //Old browser if ( typeof img.currentSrc === "undefined" ) console.log( img.src ); //Modern browser else console.log( img.currentSrc ); }
Source: https://habr.com/ru/post/1620838/More articles:Why does ReactJS handle the `checked` attr radio differently than other attrs? - javascriptExcel incorrectly activates a cell after it is selected by code in the form - excel-vbaВыбирать кнопки можно только при выборе 1/3 + 1/3 параметров радиосвязи - jsonVBA calls typed information to go to the wrong worksheet - vbaHow can I parse the LLVM MCJIT compilation result? - disassemblyDisassemble the memory - linuxDoes std :: bind include parameter data type information in C ++ 11? - c ++Cordoba iOS app getting a white flash between the deployment rocket and the first screen - iosНевозможно преобразовать MappedProjection в ProvenShape из-за двусмысленного неявного - scalaПоиск значений вектора, которые встречаются в пределах диапазона других векторных значений - rAll Articles