Function setImgWidHeiBySrc

  • Sets the width and height of all images on the page based on their src attribute. The src attribute should contain width and/or height values in the format "width=100" or "height=100". If jQuery is available, this function uses jQuery to select the images. Otherwise, it uses pure JavaScript.


    // Example images with `src` attributes containing `width` and/or `height` values
    const img1 = document.createElement('img');
    img1.setAttribute('src', '');

    const img2 = document.createElement('img');
    img2.setAttribute('src', '');

    Returns boolean

    • Returns true if images were found and their dimensions were set, otherwise false.