I need to know the actual size in pixels of a background image.
<style>
body {
background-image: url(background.jpg);
background-size: contain;
}
</style>
When I look at it when jQuery, I tried
var img = new Image;
img.src = $('body').css('background-image').replace(/url\(\"|\"\)$/ig, "");
var bgImgWidth = img.width;
var bgImgHeight = img.height;
but this brings me the size of the real image, not the size that this image gets when is displayed: if the device has 320px width, the bgImgWidth still gives me the 800px of the real image.
Does anybody has a clue on this?