Prefetch the medium photo instead of the big one #446
This commit is contained in:
parent
94c43db85b
commit
1b8dd24fe1
@ -99,22 +99,22 @@ final class Album {
|
||||
|
||||
case 'f':
|
||||
$return['public'] = '0';
|
||||
$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE star = 1 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
|
||||
$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url, medium FROM ? WHERE star = 1 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
|
||||
break;
|
||||
|
||||
case 's':
|
||||
$return['public'] = '0';
|
||||
$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE public = 1 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
|
||||
$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url, medium FROM ? WHERE public = 1 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
$return['public'] = '0';
|
||||
$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
|
||||
$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url, medium FROM ? WHERE LEFT(id, 10) >= unix_timestamp(DATE_SUB(NOW(), INTERVAL 1 DAY)) " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
|
||||
break;
|
||||
|
||||
case '0':
|
||||
$return['public'] = '0';
|
||||
$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = 0 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
|
||||
$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url, medium FROM ? WHERE album = 0 " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -122,7 +122,7 @@ final class Album {
|
||||
$albums = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
|
||||
$return = $albums->fetch_assoc();
|
||||
$return = Album::prepareData($return);
|
||||
$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url FROM ? WHERE album = '?' " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS, $this->albumIDs));
|
||||
$query = Database::prepare(Database::get(), "SELECT id, title, tags, public, star, album, thumbUrl, takestamp, url, medium FROM ? WHERE album = '?' " . Settings::get()['sortingPhotos'], array(LYCHEE_TABLE_PHOTOS, $this->albumIDs));
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ final class Photo {
|
||||
public static function prepareData(array $data) {
|
||||
|
||||
// Excepts the following:
|
||||
// (array) $data = ['id', 'title', 'tags', 'public', 'star', 'album', 'thumbUrl', 'takestamp', 'url']
|
||||
// (array) $data = ['id', 'title', 'tags', 'public', 'star', 'album', 'thumbUrl', 'takestamp', 'url', 'medium']
|
||||
|
||||
// Init
|
||||
$photo = null;
|
||||
@ -647,7 +647,11 @@ final class Photo {
|
||||
$photo['star'] = $data['star'];
|
||||
$photo['album'] = $data['album'];
|
||||
|
||||
// Parse urls
|
||||
// Parse medium
|
||||
if ($data['medium']==='1') $photo['medium'] = LYCHEE_URL_UPLOADS_MEDIUM . $data['url'];
|
||||
else $photo['medium'] = '';
|
||||
|
||||
// Parse paths
|
||||
$photo['thumbUrl'] = LYCHEE_URL_UPLOADS_THUMB . $data['thumbUrl'];
|
||||
$photo['url'] = LYCHEE_URL_UPLOADS_BIG . $data['url'];
|
||||
|
||||
|
@ -82,10 +82,12 @@ photo.preloadNext = function(photoID) {
|
||||
album.json.content[photoID].nextPhoto!='') {
|
||||
|
||||
let nextPhoto = album.json.content[photoID].nextPhoto
|
||||
let url = album.json.content[nextPhoto].url
|
||||
let medium = album.json.content[nextPhoto].medium
|
||||
|
||||
$('head [data-prefetch]').remove()
|
||||
$('head').append(`<link data-prefetch rel="prefetch" href="${ url }">`)
|
||||
if (medium!=null && medium!=='') {
|
||||
$('head [data-prefetch]').remove()
|
||||
$('head').append(`<link data-prefetch rel="prefetch" href="${ medium }">`)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user