I’m trying to adapt our blog articles in relation to Google Web Vitals and I’m struggling with CLS (cumulative layout shift) because all images don’t show dimensions with width and height in the HTML and this seems to be a Shopify problem.
My idea would now be to parse the article.content part like this: {% if article.content contains “<img” %} , does anyone have a better idea or an idea how to set my width=“” and height=“” here and write the dimensions into the HTML?
This would my idea
{% for article in blog.articles %}
{% if article.content contains "<img" %}
{% endif%}
{% endfor %}
Thanks a lot for your ideas and I’m looking forward for your input
Felix
Thanks for your reply. I actually wanted to avoid a manual adjustment, because we migrate the content and I would be take a lot of time to edit alle the blog articles
With JS, would be an option, good idea.
Do you think it would be also possible with liquid.
thanks for the JS, I added also the height. However the Google Pagespeed doesn’t see the width and height for their analysis. But this work in general.
Yes, because it will work with Javascript, meaning everything will be rendered before it starts adding, so Google Pagespeed probably won’t find it. Therefore, way 1 is the best solution for Google Pagespeed.