How to add new srcset sizes to the new responsive images update
-
I would like to create a function that adds more size options to the img srcset that came with the 4.4 update. Right now its only showing the 3 default sizes from WordPress.
I want to include the ones from:
add_image_size('maxWidth', 1920, 9999); add_image_size('laptopWidth', 1366, 9999);
WordPress current output:
<img width="1920" height="1259" src="/freddygcano%202016/wp-content/uploads/2015/12/portfolio-emtheories-1920x1259.jpg" class="attachment-maxWidth size-maxWidth wp-post-image" alt="portfolio-emtheories" srcset="/freddygcano%202016/wp-content/uploads/2015/12/portfolio-emtheories-300x197.jpg 300w, /freddygcano%202016/wp-content/uploads/2015/12/portfolio-emtheories-768x503.jpg 768w, /freddygcano%202016/wp-content/uploads/2015/12/portfolio-emtheories-1024x671.jpg 1024w" sizes="(max-width: 1920px) 100vw, 1920px">
Desired Result:
<img width="1920" height="1259" src="/freddygcano%202016/wp-content/uploads/2015/12/portfolio-emtheories-1920x1259.jpg" class="attachment-maxWidth size-maxWidth wp-post-image" alt="portfolio-emtheories" srcset="/freddygcano%202016/wp-content/uploads/2015/12/portfolio-emtheories-300x197.jpg 300w, /freddygcano%202016/wp-content/uploads/2015/12/portfolio-emtheories-768x503.jpg 768w, /freddygcano%202016/wp-content/uploads/2015/12/portfolio-emtheories-1024x671.jpg 1024w, /freddygcano%202016/wp-content/uploads/2015/12/portfolio-emtheories-1366x900.jpg 1366w, /freddygcano%202016/wp-content/uploads/2015/12/portfolio-emtheories-1920x1258.jpg 1920w" sizes="(max-width: 1920px) 100vw, 1920px">
Thanks,
Freddy G. Cano
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘How to add new srcset sizes to the new responsive images update’ is closed to new replies.