There is a function that checks the size of the image, how to make it run after the image is loaded. Otherwise, empty parameters are returned.

  • one
    <img ... onload="checkSize(this)" - Igor
  • Igor, thank you. However, my pictures are added using js and you need to run the script, the download field for all pictures. - Kula Hula
  • Please correct / complete the question. If possible, include fragments related to the question html and javascript'a. - Igor

2 answers 2

 var img = document.getElementById('img'); img.onload = function() { alert('Width: ' + this.width + 'px. Height: ' + this.height + 'px'); } 
 <img id="img" src="https://www.google.ca/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" /> 

    You can assign an onload handler:

     function checkSize(anImage) { alert($(anImage).width() + " x " + $(anImage).height()); } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <img onload="checkSize(this)" src="https://www.google.ca/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" />