@@ -117,9 +116,11 @@ build.photo = function(data) {
}
+ var {path: thumbPath, retina: thumbRetina} = lychee.retinize(data.thumbUrl);
+
html = `
-
+
${ title }
`
diff --git a/src/scripts/lychee.js b/src/scripts/lychee.js
index 0c9a805..840ced6 100644
--- a/src/scripts/lychee.js
+++ b/src/scripts/lychee.js
@@ -323,6 +323,31 @@ lychee.escapeHTML = function(s) {
}
+lychee.retinize = function(path = '') {
+
+ var pixelRatio = window.devicePixelRatio,
+ extention = path.split('.').pop();
+
+ if ((pixelRatio!==undefined&&pixelRatio>1)&&
+ (extention!=='svg')) {
+
+ path = path.replace(/\.[^/.]+$/, '');
+ path = path + '@2x' + '.' + extention;
+
+ return {
+ path,
+ retina: true
+ };
+
+ }
+
+ return {
+ path,
+ retina: false
+ };
+
+}
+
lychee.loadDropbox = function(callback) {
if (!lychee.dropbox&&lychee.dropboxKey) {
diff --git a/src/scripts/search.js b/src/scripts/search.js
index cb344d2..1a34f3e 100755
--- a/src/scripts/search.js
+++ b/src/scripts/search.js
@@ -65,7 +65,6 @@ search.find = function(term) {
} else {
lychee.content.html(html);
lychee.animate('#content', 'contentZoomIn');
- $('img[data-type!="svg"]').retina();
}
}, 300);
diff --git a/src/scripts/view.js b/src/scripts/view.js
index 0d7b72d..0b0c0fa 100644
--- a/src/scripts/view.js
+++ b/src/scripts/view.js
@@ -63,10 +63,9 @@ view.albums = {
lychee.content.html(smartData + albumsData);
}
- $('img[data-type!="nonretina"]').retina();
-
// Restore scroll position
- if (view.albums.content.scrollPosition!==null) {
+ if (view.albums.content.scrollPosition!==null&&
+ view.albums.content.scrollPosition!==0) {
$(document).scrollTop(view.albums.content.scrollPosition);
}
@@ -159,9 +158,8 @@ view.album = {
$.each(album.json.content, function() {
photosData += build.photo(this);
});
- lychee.content.html(photosData);
- $('img[data-type!="svg"]').retina();
+ lychee.content.html(photosData);
},
diff --git a/src/styles/_content.scss b/src/styles/_content.scss
index 6d97316..6878d7b 100644
--- a/src/styles/_content.scss
+++ b/src/styles/_content.scss
@@ -110,7 +110,7 @@
}
// No overlay for empty albums
- .album img[data-type^='nonretina'] + .overlay {
+ .album img[data-retina='false'] + .overlay {
background: none;
}
@@ -149,8 +149,8 @@
filter: drop-shadow(0 1px 3px black(.4));
}
- .album img[data-type^='nonretina'] + .overlay h1,
- .album img[data-type^='nonretina'] + .overlay a { text-shadow: none; }
+ .album img[data-retina='false'] + .overlay h1,
+ .album img[data-retina='false'] + .overlay a { text-shadow: none; }
/* Badges ------------------------------------------------*/
.album .badge,