Skip to content

Commit 9d7817f

Browse files
committed
Simplified for dumb lessphp
1 parent 5671145 commit 9d7817f

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

src/retina.less

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
// retina.less
22
// A helper mixin for applying high-resolution background images (http://www.retinajs.com)
33

4-
@highdpi: ~"(-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)";
54

6-
.at2x(@path, @w: auto, @h: auto) {
7-
background-image: url(@path);
8-
@at2x_path: ~`@{path}.replace(/\.\w+$/, function(match) { return "@2x" + match; })`;
5+
// If you use lessphp, complex stuff like replace won't go through. Thus I modified retina.less a bit.
96

10-
@media @highdpi {
11-
background-image: url("@{at2x_path}");
12-
background-size: @w @h;
7+
// USAGE (e.g. for semantic logo <a href=""><img src="logo.png" alt=""></a>):
8+
//
9+
// a {
10+
// width: 100px;
11+
// height: 50px;
12+
// .at2x('imagePathWithoutExt','png');
13+
// img {
14+
// display: none; // be semantic if css is off
15+
// }
16+
// }
17+
18+
// Submitted by Martin Doubravsky
19+
// martindoubravsky.com
20+
21+
.at2x(@path, @ext: png) {
22+
background-image: url(@path+'.'+@ext);
23+
24+
@media (-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) {
25+
background-image: url(@path+'@2x.'+@ext);
26+
background-size: contain;
1327
}
1428
}

0 commit comments

Comments
 (0)