diff --git a/src/UI/Handlebars/Helpers/Html.js b/src/UI/Handlebars/Helpers/Html.js
index 1866fd139..197e6cc57 100644
--- a/src/UI/Handlebars/Helpers/Html.js
+++ b/src/UI/Handlebars/Helpers/Html.js
@@ -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() {