diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index d339ae1dcb..e4a6bbd3ed 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -136,9 +136,11 @@ OCA.Sharing.PublicApp = {
scalingup: 0
};
- var imgcontainer = $('');
- var img = imgcontainer.find('.publicpreview');
+ var imgcontainer = $('');
+ if (hideDownload === 'false') {
+ imgcontainer = $('').append(imgcontainer);
+ }
+ var img = imgcontainer.hasClass('publicpreview')? imgcontainer: imgcontainer.find('.publicpreview');
img.css({
'max-width': previewWidth,
'max-height': previewHeight