Fixed data-retina

This commit is contained in:
Tobias Reich 2015-04-02 22:08:40 +02:00
parent 36793e9f9c
commit a4357ddad8
2 changed files with 6 additions and 10 deletions

View File

@ -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 = ` html = `
<div class='album' data-id='${ data.id }'> <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 = ` html = `
<div class='photo' data-album-id='${ data.album }' data-id='${ data.id }'> <div class='photo' data-album-id='${ data.album }' data-id='${ data.id }'>

View File

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