Browse Source

Fixed data-retina

Tobias Reich 9 years ago
parent
commit
a4357ddad8
2 changed files with 6 additions and 10 deletions
  1. 2 2
      src/scripts/build.js
  2. 4 8
      src/scripts/lychee.js

+ 2 - 2
src/scripts/build.js

@@ -72,7 +72,7 @@ build.album = function(data) {
 
 	}
 
-	var {path: thumbPath, retina: thumbRetina} = lychee.retinize(data.thumbs[0]);
+	var {path: thumbPath, hasRetina: thumbRetina} = lychee.retinize(data.thumbs[0]);
 
 	html =	`
 			<div class='album' data-id='${ data.id }'>
@@ -116,7 +116,7 @@ build.photo = function(data) {
 
 	}
 
-	var {path: thumbPath, retina: thumbRetina} = lychee.retinize(data.thumbUrl);
+	var {path: thumbPath, hasRetina: thumbRetina} = lychee.retinize(data.thumbUrl);
 
 	html =	`
 			<div class='photo' data-album-id='${ data.album }' data-id='${ data.id }'>

+ 4 - 8
src/scripts/lychee.js

@@ -326,24 +326,20 @@ lychee.escapeHTML = function(s) {
 lychee.retinize = function(path = '') {
 
 	var pixelRatio	= window.devicePixelRatio,
-		extention	= path.split('.').pop();
+		extention	= path.split('.').pop(),
+		hasRetina	= extention!=='svg';
 
 	if ((pixelRatio!==undefined&&pixelRatio>1)&&
-		(extention!=='svg')) {
+		(hasRetina===true)) {
 
 			path = path.replace(/\.[^/.]+$/, '');
 			path = path + '@2x' + '.' + extention;
 
-			return {
-				path,
-				retina: true
-			};
-
 	}
 
 	return {
 		path,
-		retina: false
+		hasRetina
 	};
 
 }