Get current sensitive image value on Safari

I am trying to determine the placeholder when I click on an image using the photoswipe plugin. I would like to specify exactly the same version of my responsive image as the image displayed on my screen.

data-srcset="
http://url.com/img-240.jpg 240w, 
http://url.com/img-360.jpg 360w, 
http://url.com/img-480.jpg 480w, 
http://url.com/img-720.jpg 720w "

Above are different versions of my image.

My task is to display the current image. To do this, I use a property currentSrcthat works fine on Firefox and Chrome, but not on Safari.

var currentSrc = imgEl.currentSrc || imgEl.src;

I did not find anything about a possible solution for Safari and currentSrc.

+4
source share
1 answer

naturalWidth Safari.

, naturalWidth DDR- , , WebKit DPR-. , currentSrc .

. Edge x currentSrc, , naturalWidth. Edge w currentSrc.

+5

Source: https://habr.com/ru/post/1612372/


All Articles