How to limit image download size in WordPress responsive images? -
i'm using following attachment image sizes in theme: "thumbnail" (320) "medium" (640), "medium_large" (768) , "large" (1280).
the default wordpress "srcset" , "sizes" attributes on tags causing browser download unnecessarily large images in large viewports. example, of layouts display images in grid multiple columns, it's not necessary load largest version of image in these cases.
is there way me specify maximum image size should downloaded?
specifically, tried looking way customize "srcset" attribute exclude larger 768px, can't seem figure out how this.
any advice appreciated.
try
apply_filters( 'max_srcset_image_width',int $max_width,array $size_array )
https://developer.wordpress.org/reference/hooks/max_srcset_image_width
more notes , hooks: https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpress-4-4/
Comments
Post a Comment