title: detect retina (HD) display on the server side
body: <p>I found many questions about Retina Display, but none of the answers were on the server side.</p>
  
  <p>I would like to deliver a different image according to the screen, ex (in PHP):</p>
  
  <pre><code>if( $is_retina)
      $thumbnail = get_image( $item_photo, 'thumbnail_retina' ) ;
  else
      $thumbnail = get_image( $item_photo, 'thumbnail' ) ;
  </code></pre>
  
  <p>Can you see a way of dealing with this?</p>
  
  <p>I can only imagine a test in JavaScript, setting a Cookie. However this requires an initial exchange to set it.  Anyone have a better solution?</p>
  
  <p>Cookie setting code:</p>
  
  <pre><code>(function(){
    if( document.cookie.indexOf('device_pixel_ratio') == -1
        &amp;&amp; 'devicePixelRatio' in window
        &amp;&amp; window.devicePixelRatio == 2 ){
  
      document.cookie = 'device_pixel_ratio=' + window.devicePixelRatio + ';';
      window.location.reload();
    }
  })();
  </code></pre>