mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
If image preview fails to load, just show the "no preview" message
This commit is contained in:
parent
aa301dacb9
commit
9738703424
2 changed files with 15 additions and 2 deletions
|
@ -4,15 +4,21 @@ div.binary-file.full-size(
|
|||
ng-if="openFile"
|
||||
)
|
||||
img(
|
||||
ng-show="!failedLoad"
|
||||
ng-src="/project/{{ project_id }}/file/{{ openFile.id }}"
|
||||
ng-if="['png', 'jpg', 'jpeg', 'gif'].indexOf(extension(openFile)) > -1"
|
||||
onerror="sl_binaryFilePreviewError()"
|
||||
onabort="sl_binaryFilePreviewError()"
|
||||
)
|
||||
img(
|
||||
ng-show="!failedLoad"
|
||||
ng-src="/project/{{ project_id }}/file/{{ openFile.id }}?format=png"
|
||||
ng-if="['pdf', 'eps'].indexOf(extension(openFile)) > -1"
|
||||
onerror="sl_binaryFilePreviewError()"
|
||||
onabort="sl_binaryFilePreviewError()"
|
||||
)
|
||||
p.no-preview(
|
||||
ng-if="['png', 'jpg', 'jpeg', 'gif', 'pdf', 'eps'].indexOf(extension(openFile)) == -1"
|
||||
ng-if="failedLoad || ['png', 'jpg', 'jpeg', 'gif', 'pdf', 'eps'].indexOf(extension(openFile)) == -1"
|
||||
) #{translate("no_preview_available")}
|
||||
a.btn.btn-info(
|
||||
ng-href="/project/{{ project_id }}/file/{{ openFile.id }}"
|
||||
|
|
|
@ -2,6 +2,13 @@ define [
|
|||
"base"
|
||||
], (App) ->
|
||||
App.controller "BinaryFileController", ["$scope", ($scope) ->
|
||||
|
||||
$scope.failedLoad = false
|
||||
|
||||
window.sl_binaryFilePreviewError = () =>
|
||||
$scope.failedLoad = true
|
||||
$scope.$apply()
|
||||
|
||||
$scope.extension = (file) ->
|
||||
return file.name.split(".").pop()?.toLowerCase()
|
||||
]
|
Loading…
Reference in a new issue