New: Better resolution posters on retina screens.

pull/3113/head
Jake Pusateri 9 years ago
parent 8dcd8d17b5
commit c8debbf470

@ -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() {

Loading…
Cancel
Save