Contentful logo

Contentful Community

Markdown embedded image asset details

Hi everyone I have a question about image assets embedded in a markdown field. Is there a way we aren’t seeing to include the width and height automatically for image assets embedded in markdown fields?

We would like to set the height of the image and lazy load our images. The issue we have that we need to know the width and height of the image to calculate the height it should have in the browser based on the max width of the container. For example, our content container is 600px and our image is 1200px by 800px the height would be set as 400px (image height * (container width / image width)). I know we could hit the content delivery API and get all the asset details including width and height but we would prefer not to make that many requests.