This solution works for full-screen images, and chooses the corrent sourcesbut you can use custom viewports.
This solution for all images, even if they are not full size. But on the 3x desity it still chooses wrong breakpointsHere you can use custom viewports, currently I dont know whybut it is relativ much code.
<?php $viewport = [ // Viewport => Image-Size 600 => 500, 1200 => 1000 ]; // walk over all pixel-densities for($i=3; $i>0; $i--) { foreach($viewport as $vp => $w) echo "(min-resolution: {$i}dppx) and (max-width: {$vp}px) " .roundfloor($w/$i) . "px,\n"; } ?>