Automatically add width and height attributes to image tag
Some time ago I needed to add
width attributes to all images on this blog. So I wrote a python script, here is the main idea:
- Iterate over all blog posts.
- Find all img tags in each post.
- Extract the content of the src attribute.
- Open the image and extract its size.
- Write image size in the img attribues width and height.