Skip to content

Instantly share code, notes, and snippets.

@brandonb927
Last active December 1, 2019 15:38
Show Gist options
  • Select an option

  • Save brandonb927/3874012 to your computer and use it in GitHub Desktop.

Select an option

Save brandonb927/3874012 to your computer and use it in GitHub Desktop.

Revisions

  1. Brandon Brown revised this gist Oct 4, 2014. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions image-2x.less
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    /**
    * I converted the SCSS mixin to LESS for the awesome coders like myself in response to a blog post on 37Signals - http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss
    *
    * Update: 2014-08-04 - Updated a long-standing bug where retina images were shown no matter what in the first background-image property.
    * - Updated retina media query to be more reliable ()
    * Update: 2013-11-13 - Picked up another technique thanks to reading this post from Tyler Tate, auto-fill in the second filename for the retina image, http://tylertate.com/blog/2013/06/11/retina-images-using-media-queries-and-LESS-CSS.html
    * Update: 2013-04-16 - Have recently found a few use cases when using a retina pattern from Subtle Patterns on the <body>, this has come in handy
    * Update: 2013-04-05 - Some research in the Wordpress Core(http://core.trac.wordpress.org/ticket/22238#comment:5) was pointed out that some tests may be redundant (Thanks @kbav) so I've cleaned these up
    @@ -15,10 +17,13 @@
    background-image: ~`"url(@{filename}.@{extension})"`;
    background-repeat: @repeat;

    @media print, screen,
    (-webkit-min-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi) {
    @media
    only screen and (-webkit-min-device-pixel-ratio: 2),
    only screen and ( min--moz-device-pixel-ratio: 2),
    only screen and ( -o-min-device-pixel-ratio: 2/1),
    only screen and ( min-device-pixel-ratio: 2),
    only screen and ( min-resolution: 192dpi),
    only screen and ( min-resolution: 2dppx) {
    /* on retina, use image that's scaled by 2 */
    background-image: ~`"url(@{filename}@2x.@{extension})"`;
    background-size: @width @height;
  2. Brandon Brown revised this gist Oct 4, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion image-2x.less
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    .image-2x(@image, @width, @height, @repeat: no-repeat) {
    @filename : ~`/(.*)\.(jpg|jpeg|png|gif)/.exec(@{image})[1]`;
    @extension : ~`/(.*)\.(jpg|jpeg|png|gif)/.exec(@{image})[2]`;
    background-image: ~`"url(@{filename}@2x.@{extension})"`;
    background-image: ~`"url(@{filename}.@{extension})"`;
    background-repeat: @repeat;

    @media print, screen,
  3. Brandon Brown revised this gist Feb 14, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions image-2x.less
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,7 @@
    @extension : ~`/(.*)\.(jpg|jpeg|png|gif)/.exec(@{image})[2]`;
    background-image: ~`"url(@{filename}@2x.@{extension})"`;
    background-repeat: @repeat;

    @media print, screen,
    (-webkit-min-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
  4. Brandon Brown revised this gist Feb 14, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion image-2x.less
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@
    .image-logo {
    width: 100px;
    height: 50px;
    .image-2x('image.png', 134px, 52px);
    .image-2x('image.png', 100px, 50px);
    }

    .reapeating-background-image {
  5. Brandon Brown revised this gist Feb 14, 2014. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions image-2x.less
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,11 @@
    }
    }

    /**
    * The filename convention for the retina-sized image is image@2x.png,
    * but of course you can change this in the mixin when you use it
    */

    .image-logo {
    width: 100px;
    height: 50px;
  6. Brandon Brown revised this gist Feb 14, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion image-2x.less
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@
    (-webkit-min-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi) {
    // on retina, use image that's scaled by 2
    /* on retina, use image that's scaled by 2 */
    background-image: ~`"url(@{filename}@2x.@{extension})"`;
    background-size: @width @height;
    }
  7. Brandon Brown revised this gist Feb 14, 2014. 1 changed file with 10 additions and 9 deletions.
    19 changes: 10 additions & 9 deletions image-2x.less
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,13 @@
    // I converted the SCSS mixin to LESS for the awesome coders like myself in response to a blog post on 37Signals - http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss

    // Update: 2013-11-13 - Picked up another technique thanks to reading this post from Tyler Tate, auto-fill in the second filename for the retina image, http://tylertate.com/blog/2013/06/11/retina-images-using-media-queries-and-LESS-CSS.html
    // Update: 2013-04-16 - Have recently found a few use cases when using a retina pattern from Subtle Patterns on the <body>, this has come in handy
    // Update: 2013-04-05 - Some research in the Wordpress Core(http://core.trac.wordpress.org/ticket/22238#comment:5) was pointed out that some tests may be redundant (Thanks @kbav) so I've cleaned these up
    // Update: 2012-12-29 - Updated AGAIN to add MS IE10 declaration and fix wonky 'min--moz-' declaration which Mozilla engineers are aware of
    // Update: 2012-11-21 - Updated again based on information from an article I found, added dppx and changed opera ratio to target more devices (http://www.uifuel.com/hd-retina-display-media-queries/)
    // Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)

    /**
    * I converted the SCSS mixin to LESS for the awesome coders like myself in response to a blog post on 37Signals - http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss
    *
    * Update: 2013-11-13 - Picked up another technique thanks to reading this post from Tyler Tate, auto-fill in the second filename for the retina image, http://tylertate.com/blog/2013/06/11/retina-images-using-media-queries-and-LESS-CSS.html
    * Update: 2013-04-16 - Have recently found a few use cases when using a retina pattern from Subtle Patterns on the <body>, this has come in handy
    * Update: 2013-04-05 - Some research in the Wordpress Core(http://core.trac.wordpress.org/ticket/22238#comment:5) was pointed out that some tests may be redundant (Thanks @kbav) so I've cleaned these up
    * Update: 2012-12-29 - Updated AGAIN to add MS IE10 declaration and fix wonky 'min--moz-' declaration which Mozilla engineers are aware of
    * Update: 2012-11-21 - Updated again based on information from an article I found, added dppx and changed opera ratio to target more devices (http://www.uifuel.com/hd-retina-display-media-queries/)
    * Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)
    */

    .image-2x(@image, @width, @height, @repeat: no-repeat) {
    @filename : ~`/(.*)\.(jpg|jpeg|png|gif)/.exec(@{image})[1]`;
  8. Brandon Brown renamed this gist Feb 14, 2014. 1 changed file with 17 additions and 17 deletions.
    34 changes: 17 additions & 17 deletions gistfile1.less → image-2x.less
    Original file line number Diff line number Diff line change
    @@ -9,27 +9,27 @@


    .image-2x(@image, @width, @height, @repeat: no-repeat) {
    @filename : ~`/(.*)\.(jpg|jpeg|png|gif)/.exec(@{image})[1]`;
    @extension : ~`/(.*)\.(jpg|jpeg|png|gif)/.exec(@{image})[2]`;
    background-image: ~`"url(@{filename}@2x.@{extension})"`;
    background-repeat: @repeat;
    @media print, screen,
    (-webkit-min-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi) {
    // on retina, use image that's scaled by 2
    background-image: ~`"url(@{filename}@2x.@{extension})"`;
    background-size: @width @height;
    }
    @filename : ~`/(.*)\.(jpg|jpeg|png|gif)/.exec(@{image})[1]`;
    @extension : ~`/(.*)\.(jpg|jpeg|png|gif)/.exec(@{image})[2]`;
    background-image: ~`"url(@{filename}@2x.@{extension})"`;
    background-repeat: @repeat;
    @media print, screen,
    (-webkit-min-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi) {
    // on retina, use image that's scaled by 2
    background-image: ~`"url(@{filename}@2x.@{extension})"`;
    background-size: @width @height;
    }
    }

    .image-logo {
    width: 100px;
    height: 50px;
    .image-2x('image.png', 134px, 52px);
    width: 100px;
    height: 50px;
    .image-2x('image.png', 134px, 52px);
    }

    .reapeating-background-image {
    background-color: #444;
    .image-2x('image.png', 200px, 200px, repeat);
    background-color: #444;
    .image-2x('image.png', 200px, 200px, repeat);
    }
  9. Brandon Brown renamed this gist Feb 14, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  10. Brandon Brown revised this gist Feb 14, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -26,10 +26,10 @@
    .image-logo {
    width: 100px;
    height: 50px;
    .image-2x('image.png', 'image@2x.png', 134px, 52px);
    .image-2x('image.png', 134px, 52px);
    }

    .reapeating-background-image {
    background-color: #444;
    .image-2x('image.png', 'image@2X.png', 200px, 200px, repeat);
    .image-2x('image.png', 200px, 200px, repeat);
    }
  11. brandonb927 revised this gist Jan 16, 2014. 1 changed file with 0 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,10 @@
    // I converted the SCSS mixin to LESS for the awesome coders like myself in response to a blog post on 37Signals - http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss

    // Update: 2013-11-13 - Picked up another technique thanks to reading this post from Tyler Tate, auto-fill in the second filename for the retina image, http://tylertate.com/blog/2013/06/11/retina-images-using-media-queries-and-LESS-CSS.html

    // Update: 2013-04-16 - Have recently found a few use cases when using a retina pattern from Subtle Patterns on the <body>, this has come in handy

    // Update: 2013-04-05 - Some research in the Wordpress Core(http://core.trac.wordpress.org/ticket/22238#comment:5) was pointed out that some tests may be redundant (Thanks @kbav) so I've cleaned these up

    // Update: 2012-12-29 - Updated AGAIN to add MS IE10 declaration and fix wonky 'min--moz-' declaration which Mozilla engineers are aware of

    // Update: 2012-11-21 - Updated again based on information from an article I found, added dppx and changed opera ratio to target more devices (http://www.uifuel.com/hd-retina-display-media-queries/)

    // Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)


  12. brandonb927 renamed this gist Nov 13, 2013. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions gistfile1 → gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    // I converted the SCSS mixin to LESS for the awesome coders like myself in response to a blog post on 37Signals - http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss

    // Update: 2013-11-13 - Picked up another technique thanks to reading this post from Tyler Tate, auto-fill in the second filename for the retina image, http://tylertate.com/blog/2013/06/11/retina-images-using-media-queries-and-LESS-CSS.html

    // Update: 2013-04-16 - Have recently found a few use cases when using a retina pattern from Subtle Patterns on the <body>, this has come in handy

    // Update: 2013-04-05 - Some research in the Wordpress Core(http://core.trac.wordpress.org/ticket/22238#comment:5) was pointed out that some tests may be redundant (Thanks @kbav) so I've cleaned these up
    @@ -10,17 +12,20 @@

    // Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)

    .image-2x(@image1, @image2, @width, @height, @repeat: no-repeat) {
    background-image: url('@{image1}');

    .image-2x(@image, @width, @height, @repeat: no-repeat) {
    @filename : ~`/(.*)\.(jpg|jpeg|png|gif)/.exec(@{image})[1]`;
    @extension : ~`/(.*)\.(jpg|jpeg|png|gif)/.exec(@{image})[2]`;
    background-image: ~`"url(@{filename}@2x.@{extension})"`;
    background-repeat: @repeat;
    @media print, screen,
    (-webkit-min-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi) {
    // on retina, use image that's scaled by 2
    background-image: url('@{image2}');
    background-image: ~`"url(@{filename}@2x.@{extension})"`;
    background-size: @width @height;
    .background-size(@width, @height); }
    }
    }

    .image-logo {
  13. Brandon Brown revised this gist Apr 16, 2013. 1 changed file with 14 additions and 7 deletions.
    21 changes: 14 additions & 7 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    // I converted the SCSS mixin to LESS for the lazy coders like myself in response to this blog post (http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss)
    // I converted the SCSS mixin to LESS for the awesome coders like myself in response to a blog post on 37Signals - http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss

    // Update: 2013-04-16 - Have recently found a few use cases when using a retina pattern from Subtle Patterns on the <body>, this has come in handy

    // Update: 2013-04-05 - Some research in the Wordpress Core(http://core.trac.wordpress.org/ticket/22238#comment:5) was pointed out that some tests may be redundant (Thanks @kbav) so I've cleaned these up

    @@ -8,21 +10,26 @@

    // Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)

    .image-2x(@image1, @image2, @width, @height) {
    .image-2x(@image1, @image2, @width, @height, @repeat: no-repeat) {
    background-image: url('@{image1}');
    background-repeat: no-repeat;
    @media
    print,
    (-o-min-device-pixel-ratio: 5/4),
    background-repeat: @repeat;
    @media print, screen,
    (-webkit-min-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi) {
    // on retina, use image that's scaled by 2
    background-image: url('@{image2}');
    background-size: @width @height; }
    background-size: @width @height;
    .background-size(@width, @height); }
    }

    .image-logo {
    width: 100px;
    height: 50px;
    .image-2x('image.png', 'image@2x.png', 134px, 52px);
    }

    .reapeating-background-image {
    background-color: #444;
    .image-2x('image.png', 'image@2X.png', 200px, 200px, repeat);
    }
  14. Brandon Brown revised this gist Apr 6, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,8 @@
    // Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)

    .image-2x(@image1, @image2, @width, @height) {
    background-image: url('@{image1}') no-repeat;
    background-image: url('@{image1}');
    background-repeat: no-repeat;
    @media
    print,
    (-o-min-device-pixel-ratio: 5/4),
  15. Brandon Brown revised this gist Apr 6, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    // Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)

    .image-2x(@image1, @image2, @width, @height) {
    background-image: url('@{image}') no-repeat;
    background-image: url('@{image1}') no-repeat;
    @media
    print,
    (-o-min-device-pixel-ratio: 5/4),
  16. Brandon Brown revised this gist Apr 6, 2013. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -12,10 +12,9 @@
    background-image: url('@{image}') no-repeat;
    @media
    print,
    (~`"-o-min-device-pixel-ratio: 1.25/1"`),
    (-o-min-device-pixel-ratio: 5/4),
    (-webkit-min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi),
    (min-resolution: 1.25dppx) {
    (min-resolution: 120dpi) {
    // on retina, use image that's scaled by 2
    background-image: url('@{image2}');
    background-size: @width @height; }
  17. Brandon Brown revised this gist Apr 6, 2013. 1 changed file with 20 additions and 23 deletions.
    43 changes: 20 additions & 23 deletions gistfile1
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,28 @@
    I converted the SCSS mixin to LESS for the lazy coders like myself in response to this blog post (http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss)
    // I converted the SCSS mixin to LESS for the lazy coders like myself in response to this blog post (http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss)

    Update: 2012-12-29 - Updated AGAIN to add MS IE10 declaration and fix wonky 'min--moz-' declaration which Mozilla engineers are aware of
    // Update: 2013-04-05 - Some research in the Wordpress Core(http://core.trac.wordpress.org/ticket/22238#comment:5) was pointed out that some tests may be redundant (Thanks @kbav) so I've cleaned these up

    Update: 2012-11-21 - Updated again based on information from an article I found, added dppx and changed opera ratio to target more devices (http://www.uifuel.com/hd-retina-display-media-queries/)
    // Update: 2012-12-29 - Updated AGAIN to add MS IE10 declaration and fix wonky 'min--moz-' declaration which Mozilla engineers are aware of

    Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)
    // Update: 2012-11-21 - Updated again based on information from an article I found, added dppx and changed opera ratio to target more devices (http://www.uifuel.com/hd-retina-display-media-queries/)

    .image-2x(@image, @width, @height) {
    @media print,
    screen,
    (-webkit-min-device-pixel-ratio: 1.25),
    (~`"-o-min-device-pixel-ratio: 1.25/1"`),
    (min--moz-device-pixel-ratio: 1.25),
    (-moz-min-device-pixel-ratio: 1.25),
    (-ms-min-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi),
    (min-resolution: 1.25dppx) {
    /* on retina, use image that's scaled by 2 */
    background-image: url('@{image}');
    background-size: @width @height;
    }
    // Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)

    .image-2x(@image1, @image2, @width, @height) {
    background-image: url('@{image}') no-repeat;
    @media
    print,
    (~`"-o-min-device-pixel-ratio: 1.25/1"`),
    (-webkit-min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi),
    (min-resolution: 1.25dppx) {
    // on retina, use image that's scaled by 2
    background-image: url('@{image2}');
    background-size: @width @height; }
    }

    .image-logo {
    width: 100px;
    height: 50px;
    background: url('image.png') no-repeat;
    .image-2x('image@2x.png', 134px, 52px);
    width: 100px;
    height: 50px;
    .image-2x('image.png', 'image@2x.png', 134px, 52px);
    }
  18. Brandon Brown renamed this gist Dec 29, 2012. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.txt → gistfile1
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    I converted the SCSS mixin to LESS for the lazy coders like myself in response to this blog post (http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss)

    Update: 2012-12-29 - Updated AGAIN to add MS IE10 declaration and fix wonky 'min--moz-' declaration which Mozilla engineers are aware of

    Update: 2012-11-21 - Updated again based on information from an article I found, added dppx and changed opera ratio to target more devices (http://www.uifuel.com/hd-retina-display-media-queries/)

    Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)
    @@ -10,6 +12,8 @@ Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices
    (-webkit-min-device-pixel-ratio: 1.25),
    (~`"-o-min-device-pixel-ratio: 1.25/1"`),
    (min--moz-device-pixel-ratio: 1.25),
    (-moz-min-device-pixel-ratio: 1.25),
    (-ms-min-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi),
    (min-resolution: 1.25dppx) {
  19. Brandon Brown revised this gist Nov 23, 2012. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,18 @@
    I converted the SCSS mixin to LESS for the lazy coders like myself in response to this blog post (http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss)

    Update: 2012-11-21 - Updated again based on information from an article I found, added dppx and changed opera ratio to target more devices (http://www.uifuel.com/hd-retina-display-media-queries/)

    Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)

    .image-2x(@image, @width, @height) {
    @media print,
    screen,
    (-webkit-min-device-pixel-ratio: 1.25),
    (-o-min-device-pixel-ratio: 5/4),
    (~`"-o-min-device-pixel-ratio: 1.25/1"`),
    (min--moz-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi) {
    (min-resolution: 120dpi),
    (min-resolution: 1.25dppx) {
    /* on retina, use image that's scaled by 2 */
    background-image: url('@{image}');
    background-size: @width @height;
  20. Brandon Brown revised this gist Nov 17, 2012. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,13 @@ I converted the SCSS mixin to LESS for the lazy coders like myself in response t
    Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)

    .image-2x(@image, @width, @height) {
    @media only screen and (-webkit-min-device-pixel-ratio: 1.25),
    only screen and (-o-min-device-pixel-ratio: 5/4),
    only screen and (min--moz-device-pixel-ratio: 1.25),
    only screen and (min-device-pixel-ratio: 1.25),
    only screen and (min-resolution: 120dpi) {
    @media print,
    screen,
    (-webkit-min-device-pixel-ratio: 1.25),
    (-o-min-device-pixel-ratio: 5/4),
    (min--moz-device-pixel-ratio: 1.25),
    (min-device-pixel-ratio: 1.25),
    (min-resolution: 120dpi) {
    /* on retina, use image that's scaled by 2 */
    background-image: url('@{image}');
    background-size: @width @height;
  21. Brandon Brown revised this gist Nov 17, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    I converted the SCSS mixin to LESS for the lazy coders like myself in response to this blog post (http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss)

    Update: 2012-11-17 - Updated based on Wordpress Core to target even more devices! Thanks @Wordpress <3 (http://core.trac.wordpress.org/changeset/22629)

    .image-2x(@image, @width, @height) {
    @media only screen and (-webkit-min-device-pixel-ratio: 1.25),
    only screen and (-o-min-device-pixel-ratio: 5/4),
  22. Brandon Brown revised this gist Nov 17, 2012. 1 changed file with 13 additions and 13 deletions.
    26 changes: 13 additions & 13 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,20 @@
    I converted the SCSS mixin to LESS for the lazy coders like myself in response to this blog post (http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss)

    .image-2x(@image, @width, @height) {
    @media only screen and (-webkit-min-device-pixel-ratio: 1.3),
    only screen and (-o-min-device-pixel-ratio: 3/2),
    only screen and (min--moz-device-pixel-ratio: 1.3),
    only screen and (min-device-pixel-ratio: 1.3),
    only screen and (min-resolution: 1.3dppx) {
    /* on retina, use image that's scaled by 2 */
    background-image: url('@{image}');
    background-size: @width @height;
    }
    @media only screen and (-webkit-min-device-pixel-ratio: 1.25),
    only screen and (-o-min-device-pixel-ratio: 5/4),
    only screen and (min--moz-device-pixel-ratio: 1.25),
    only screen and (min-device-pixel-ratio: 1.25),
    only screen and (min-resolution: 120dpi) {
    /* on retina, use image that's scaled by 2 */
    background-image: url('@{image}');
    background-size: @width @height;
    }
    }

    .image-logo {
    width: 100px;
    height: 50px;
    background: url('image.png') no-repeat;
    .image-2x('image@2x.png', 134px, 52px);
    width: 100px;
    height: 50px;
    background: url('image.png') no-repeat;
    .image-2x('image@2x.png', 134px, 52px);
    }
  23. brandonb927 revised this gist Oct 11, 2012. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    I converted the SCSS mixin to LESS for the lazy coders like myself in response to this blog post (http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss)

    .image-2x(@image, @width, @height) {
    @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
    @media only screen and (-webkit-min-device-pixel-ratio: 1.3),
    only screen and (-o-min-device-pixel-ratio: 3/2),
    only screen and (min--moz-device-pixel-ratio: 1.5),
    only screen and (min-device-pixel-ratio: 1.5),
    only screen and (min--moz-device-pixel-ratio: 1.3),
    only screen and (min-device-pixel-ratio: 1.3),
    only screen and (min-resolution: 1.3dppx) {
    /* on retina, use image that's scaled by 2 */
    background-image: url('@{image}');
  24. brandonb927 created this gist Oct 11, 2012.
    20 changes: 20 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    I converted the SCSS mixin to LESS for the lazy coders like myself in response to this blog post (http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss)

    .image-2x(@image, @width, @height) {
    @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
    only screen and (-o-min-device-pixel-ratio: 3/2),
    only screen and (min--moz-device-pixel-ratio: 1.5),
    only screen and (min-device-pixel-ratio: 1.5),
    only screen and (min-resolution: 1.3dppx) {
    /* on retina, use image that's scaled by 2 */
    background-image: url('@{image}');
    background-size: @width @height;
    }
    }

    .image-logo {
    width: 100px;
    height: 50px;
    background: url('image.png') no-repeat;
    .image-2x('image@2x.png', 134px, 52px);
    }