/* Function */ .retina(@path, @cap: 2, @size: auto auto, @extras: ~'') { @lowretina: ~"(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)"; @2xpath: ~`@{path}.replace(/\.\w+$/, function(match) { return "@2x" + match; })`; background: url(@path) @extras; background-size: @size; @media @lowretina { background : url(@2xpath) @extras; background-size : @size; } .create-queries() when (@cap >= 2) { .loop(@env) when (@env <= @cap) { @retinapath: ~`@{path}.replace(/\.\w+$/, function(match) { return "@@{env}x" + match; })`; @media (-webkit-min-device-pixel-ratio: @env), (min-resolution: @env * 96dpi) { background : url(@retinapath) @extras; background-size : @size; } .loop((@env + 1)); } .loop(2); } .create-queries(); } /* Retina Stylesheet */ body { .retina('../../main/images/cc_body_notrans.png', 3, 1088px 510px, top center repeat); }