Avoid auto generating srcset after filling img width & height attributes
Hey! I'm working on my own responsive image function that serves proper image sizes combined with custom lazy load function. I'm using resize_image_url which works great but everything breaks down after filling width & height attributes, because then hubspot generates srcset automatically and overrides my <source>'s rules.
I want to fill width & height as it's good practice.
Is there any possibility to disable autogenerating srcset after filling width/height?
I know that the simple solution is just to not set width="" or height="" attribute, but this is good practice regarding e.g. performance so this is important to me.
But it looks that I've already found solution. Adding `?noresize` parameter to the url inside src="" attribute avoids this situation.
Sep 23, 20228:16 AM - edited Sep 23, 20228:17 AM
Top Contributor | Platinum Partner
Avoid auto generating srcset after filling img width & height attributes
I'm not familiar with the noresize url parameter and I'm not quite sure what it does, is there some documentation on this? I would like to dig more into it.
On another note, the proposed solution is to add width and height to the image - as you very well pointed is good practice because of page reflow during load times - but you should add it to the css with media queries, as now you are going to load the image in various sizes so for example, for the small image it doesn't make sense to declare a width of 800px because the image will end up using only 480px;
This is why with the srcset attribute you shouldn't use width and height attributes, instead add the corresponding css. This will look like the following (I'm adding just the css for my html I shared previously):