1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

New: Better resolution posters on retina screens.

This commit is contained in:
Jake Pusateri 2015-12-27 12:39:32 -08:00
parent 8dcd8d17b5
commit c8debbf470

View File

@ -14,15 +14,24 @@ window.NzbDrone.imageError = function(img) {
}; };
Handlebars.registerHelper('defaultImg', function(src, size) { Handlebars.registerHelper('defaultImg', function(src, size) {
var endOfPath = /\.jpg($|\?)/g;
var errorAttr = 'onerror="window.NzbDrone.imageError(this);"';
var srcsetAttr = '';
var oneX = src, twoX;
if (!src) { if (!src) {
return new Handlebars.SafeString('onerror="window.NzbDrone.imageError(this);"'); return new Handlebars.SafeString(errorAttr);
} }
if (size) { if (size) {
src = src.replace(/\.jpg($|\?)/g, '-' + size + '.jpg$1'); oneX = src.replace(endOfPath, '-' + size + '.jpg$1');
twoX = src.replace(endOfPath, '-' + size * 2 + '.jpg$1');
srcsetAttr = 'srcset="{0} 1x, {1} 2x"'.format(oneX, twoX);
} }
return new Handlebars.SafeString('src="{0}" onerror="window.NzbDrone.imageError(this);"'.format(src)); return new Handlebars.SafeString(
'src="{0}" {1} {2}'.format(oneX, srcsetAttr, errorAttr)
);
}); });
Handlebars.registerHelper('UrlBase', function() { Handlebars.registerHelper('UrlBase', function() {