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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -