var img = $ ("#img_id"); Get my img elemvar pic_real_width, pic_real_height;$ ("
Technically, we can easily limit the picture with the maximum width of the text, so that all of them remain one width, without the width of the text, we need each picture's own size. We can declare the original size of the picture when the server is edited. A more flexible way is to dynamically get the original size of the image by placing a section of JS on the page, dynamically changing the image's display size. This is compatible with the old and also the maximum width of the text way, you can also let the picture when needed to show its original size.
WebKit Browser (Google Chrome, etc.) is the image of the loaded event before you get the height and width values. So, you can't delay waiting with the timeout function, the best way is to use the OnLoad event of the picture.
To avoid the effect of CSS on the size and size of a picture, the above code copies the image into memory for calculation.
If your page is an old-fashioned page, you can embed the code on the bottom of the page as needed, and it doesn't require you to modify the original page.
How do I get the original size of a picture in JavaScript on the browser side?