{"id":2286,"date":"2021-10-04T12:23:46","date_gmt":"2021-10-04T06:53:46","guid":{"rendered":"https:\/\/imageattributespro.com\/?p=2286"},"modified":"2023-04-25T10:06:40","modified_gmt":"2023-04-25T04:36:40","slug":"add-missing-image-dimensions","status":"publish","type":"post","link":"https:\/\/imageattributespro.com\/add-missing-image-dimensions\/","title":{"rendered":"Add Missing Image Dimensions (Width And Height) To Prevent Layout Shift"},"content":{"rendered":"

Your browser does not know the dimensions of the image before the image is downloaded. So the browser has no idea how much space the image is going to take up once it’s downloaded. <\/p>

To accommodate the image, the browser will have to move around the content once the image is loaded. You can see this in the gif below. The content is moved around once the screenshot is loaded. <\/p>

\"Image<\/figure>

Specifying the width and height of images on your page helps browsers reserve the space required for the image to load. <\/p>

Since users start reading your website before images are loaded, preventing layout shift leads to better user experience for your users. <\/strong><\/p>

Pro Tip<\/strong>: Google now takes into account user experience as part of ranking websites for SEO. Layout shifts is one of the criteria and it’s measured as Cumulative Layout Shift<\/a> or CLS. <\/p>

Adding image dimensions will help improve your CLS score on PageSpeed<\/strong> and satisfy the “Image elements do not have explicit width and height” suggestions. <\/p>

Adding Missing Image Dimensions With Image Attributes Pro<\/h2>

Image Attributes Pro 1.4 added a new filter iaffpro_html_image_markup_post_update<\/a><\/code>. We will be using this filter to add missing image width and height. <\/p>