Set the width and height of an image based on the parameters specified in the image's URL.
Use jQuery to select all img elements on the page and then checks each image's src attribute for width and height parameters. If these parameters are found, the function sets the image's width and height accordingly.
The width and height parameters in the URL should be in the format width=<value><unit> and height=<value><unit>, where <value> is a number and <unit> is a CSS unit like px, rem, or vw.
Example 1:
For an image with the URL <img src="https://example.com/image.png?width=400px&height=200px" alt="file" />, the function will execute window.jQuery('img').width('400px') and window.jQuery('img').height('200px').
Example 2:
For an image with the URL <img src="https://example.com/image.png?width=400rem&height=20vw" alt="file" />, the function will execute window.jQuery('img').width('400rem') and window.jQuery('img').height('20vw').
Returns boolean
Returns true if jQuery is available and the function was able to run, false otherwise.
Set the width and height of an image based on the parameters specified in the image's URL.
Use jQuery to select all
imgelements on the page and then checks each image'ssrcattribute forwidthandheightparameters. If these parameters are found, the function sets the image's width and height accordingly.The width and height parameters in the URL should be in the format
width=<value><unit>andheight=<value><unit>, where<value>is a number and<unit>is a CSS unit likepx,rem, orvw.Example 1: For an image with the URL
<img src="https://example.com/image.png?width=400px&height=200px" alt="file" />, the function will executewindow.jQuery('img').width('400px')andwindow.jQuery('img').height('200px').Example 2: For an image with the URL
<img src="https://example.com/image.png?width=400rem&height=20vw" alt="file" />, the function will executewindow.jQuery('img').width('400rem')andwindow.jQuery('img').height('20vw').