|
60 | 60 | var isImage = model.isImage(); |
61 | 61 | var maxImageWidth = $thumbnailContainer.parent().width() + 50; // 50px for negative margins |
62 | 62 | var maxImageHeight = maxImageWidth / (16 / 9); |
63 | | - var smallPreviewSize = 75; |
64 | 63 |
|
65 | 64 | var isLandscape = function (img) { |
66 | 65 | return img.width > (img.height * 1.2); |
|
71 | 70 | }; |
72 | 71 |
|
73 | 72 | var getTargetHeight = function (img) { |
74 | | - if (isImage) { |
75 | | - var targetHeight = img.height / window.devicePixelRatio; |
76 | | - if (targetHeight <= smallPreviewSize) { |
77 | | - targetHeight = smallPreviewSize; |
78 | | - } |
79 | | - return targetHeight; |
80 | | - } else { |
81 | | - return smallPreviewSize; |
| 73 | + var targetHeight = img.height / window.devicePixelRatio; |
| 74 | + if (targetHeight <= maxImageHeight) { |
| 75 | + targetHeight = maxImageHeight; |
82 | 76 | } |
| 77 | + return targetHeight; |
83 | 78 | }; |
84 | 79 |
|
85 | 80 | var getTargetRatio = function (img) { |
|
96 | 91 | path: model.getFullPath(), |
97 | 92 | mime: model.get('mimetype'), |
98 | 93 | etag: model.get('etag'), |
99 | | - y: isImage ? maxImageHeight : smallPreviewSize, |
100 | | - x: isImage ? maxImageWidth : smallPreviewSize, |
101 | | - a: isImage ? 1 : null, |
102 | | - mode: isImage ? 'cover' : null, |
| 94 | + y: maxImageHeight, |
| 95 | + x: maxImageWidth, |
| 96 | + a: 1, |
| 97 | + mode: 'cover', |
103 | 98 | callback: function (previewUrl, img) { |
104 | 99 | $thumbnailDiv.previewImg = previewUrl; |
105 | 100 |
|
|
109 | 104 | } |
110 | 105 | $thumbnailDiv.removeClass('icon-loading icon-32'); |
111 | 106 | var targetHeight = getTargetHeight(img); |
112 | | - if (isImage && targetHeight > smallPreviewSize) { |
113 | | - $thumbnailContainer.addClass((isLandscape(img) && !isSmall(img)) ? 'landscape' : 'portrait'); |
114 | | - $thumbnailContainer.addClass('large'); |
115 | | - } |
| 107 | + $thumbnailContainer.addClass((isLandscape(img) && !isSmall(img)) ? 'landscape' : 'portrait'); |
| 108 | + $thumbnailContainer.addClass('large'); |
116 | 109 |
|
117 | 110 | // only set background when we have an actual preview |
118 | 111 | // when we don't have a preview we show the mime icon in the error handler |
119 | 112 | $thumbnailDiv.css({ |
120 | 113 | 'background-image': 'url("' + previewUrl + '")', |
121 | | - height: (targetHeight > smallPreviewSize) ? 'auto' : targetHeight, |
| 114 | + height: (targetHeight > maxImageHeight) ? 'auto' : targetHeight, |
122 | 115 | 'max-height': isSmall(img) ? targetHeight : null |
123 | 116 | }); |
124 | 117 |
|
|
0 commit comments