1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-29 03:15:19 +00: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) {
var endOfPath = /\.jpg($|\?)/g;
var errorAttr = 'onerror="window.NzbDrone.imageError(this);"';
var srcsetAttr = '';
var oneX = src, twoX;
if (!src) {
return new Handlebars.SafeString('onerror="window.NzbDrone.imageError(this);"');
return new Handlebars.SafeString(errorAttr);
}
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() {