|
1589 | 1589 | urlSpec = {}; |
1590 | 1590 | ready(iconURL); // set mimeicon URL |
1591 | 1591 |
|
1592 | | - urlSpec.file = OCA.Files.Files.fixPath(path); |
1593 | | - if (options.x) { |
1594 | | - urlSpec.x = options.x; |
1595 | | - } |
1596 | | - if (options.y) { |
1597 | | - urlSpec.y = options.y; |
1598 | | - } |
1599 | | - if (options.a) { |
1600 | | - urlSpec.a = options.a; |
1601 | | - } |
1602 | | - if (options.mode) { |
1603 | | - urlSpec.mode = options.mode; |
1604 | | - } |
| 1592 | + var img = new Image(); |
1605 | 1593 |
|
1606 | | - if (etag){ |
1607 | | - // use etag as cache buster |
1608 | | - urlSpec.c = etag; |
1609 | | - } |
| 1594 | + if (oc_appconfig.core.previewsEnabled) { |
| 1595 | + urlSpec.file = OCA.Files.Files.fixPath(path); |
| 1596 | + if (options.x) { |
| 1597 | + urlSpec.x = options.x; |
| 1598 | + } |
| 1599 | + if (options.y) { |
| 1600 | + urlSpec.y = options.y; |
| 1601 | + } |
| 1602 | + if (options.a) { |
| 1603 | + urlSpec.a = options.a; |
| 1604 | + } |
| 1605 | + if (options.mode) { |
| 1606 | + urlSpec.mode = options.mode; |
| 1607 | + } |
1610 | 1608 |
|
1611 | | - previewURL = self.generatePreviewUrl(urlSpec); |
1612 | | - previewURL = previewURL.replace('(', '%28'); |
1613 | | - previewURL = previewURL.replace(')', '%29'); |
| 1609 | + if (etag) { |
| 1610 | + // use etag as cache buster |
| 1611 | + urlSpec.c = etag; |
| 1612 | + } |
1614 | 1613 |
|
1615 | | - // preload image to prevent delay |
1616 | | - // this will make the browser cache the image |
1617 | | - var img = new Image(); |
1618 | | - img.onload = function(){ |
1619 | | - // if loading the preview image failed (no preview for the mimetype) then img.width will < 5 |
1620 | | - if (img.width > 5) { |
1621 | | - ready(previewURL, img); |
1622 | | - } else if (options.error) { |
1623 | | - options.error(); |
| 1614 | + previewURL = self.generatePreviewUrl(urlSpec); |
| 1615 | + previewURL = previewURL.replace('(', '%28'); |
| 1616 | + previewURL = previewURL.replace(')', '%29'); |
| 1617 | + |
| 1618 | + // preload image to prevent delay |
| 1619 | + // this will make the browser cache the image |
| 1620 | + img.onload = function () { |
| 1621 | + // if loading the preview image failed (no preview for the mimetype) then img.width will < 5 |
| 1622 | + if (img.width > 5) { |
| 1623 | + ready(previewURL, img); |
| 1624 | + } else if (options.error) { |
| 1625 | + options.error(); |
| 1626 | + } |
| 1627 | + }; |
| 1628 | + if (options.error) { |
| 1629 | + img.onerror = options.error; |
1624 | 1630 | } |
1625 | | - }; |
1626 | | - if (options.error) { |
1627 | | - img.onerror = options.error; |
| 1631 | + img.src = previewURL; |
| 1632 | + } else { |
| 1633 | + ready(iconURL, img); |
1628 | 1634 | } |
1629 | | - img.src = previewURL; |
1630 | 1635 | }, |
1631 | 1636 |
|
1632 | 1637 | /** |
|
0 commit comments