Width 100%: Aspect ratio of image

If I add an image to a post, WordPress hardcodes width and height attributes to the img tag.

I added max-width:100% to my CSS, but of course, if my browser window gets smaller, the resized image gets stretched in height.

Read More

What can I do about it?

Is there a way to:

A: Solve it with CSS (I would prefer that)?
B: Forbid WP to hardcode width and height?
or
C: Is there a common way of dealing with image widths, I’m not aware of?

Related posts

1 comment

  1. A + C:

    img.resize-proportionally {
        max-width: 100%;
        height: auto;
    }
    

    As an aside, for the above to work, you shouldn’t attempt B.
    Having width and height attributes in the img tag is good.

Comments are closed.