Skip to content

Commit cc82741

Browse files
danxuliunextcloud-command
authored andcommitted
Fix path to image resources
When "./js/pdfjs/web/images/" is resolved and pretty URLs are enabled the result is "{SERVER}/apps/files_pdfviewer/js/pdfjs/web/images/", which works as expected. However, if pretty URLs are not enabled the absolute path becomes "{SERVER}/index.php/apps/files_pdfviewer/js/pdfjs/web/images/" instead. As the images are static files they are not served by "index.php", so they can not be found and therefore are not rendered in the PDF. To solve that now the path is generated in PHP and provided through the template, similarly to how it is done, for example, for the path to the cmap files. Signed-off-by: Daniel Calviño Sánchez <[email protected]> Signed-off-by: nextcloud-command <[email protected]>
1 parent 7ccf117 commit cc82741

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

js/files_pdfviewer-workersrc.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/files_pdfviewer-workersrc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/workersrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function initializeCustomPDFViewerApplication() {
2929
PDFViewerApplicationOptions.set('cMapUrl', head.getAttribute('data-cmapurl'))
3030
PDFViewerApplicationOptions.set('sandboxBundleSrc', head.getAttribute('data-sandbox'))
3131
PDFViewerApplicationOptions.set('enablePermissions', true)
32-
PDFViewerApplicationOptions.set('imageResourcesPath', './js/pdfjs/web/images/')
32+
PDFViewerApplicationOptions.set('imageResourcesPath', head.getAttribute('data-imageresourcespath'))
3333
PDFViewerApplicationOptions.set('enableScripting', head.getAttribute('data-enableScripting') === true)
3434

3535
if (hideDownload === '1') {

templates/viewer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
<head data-workersrc="<?php p($urlGenerator->linkTo('files_pdfviewer', 'js/pdfjs/build/pdf.worker.js')) ?>?v=<?php p($version) ?>"
4343
data-enableScripting="<?php p($enableScripting ? true : false) ?>"
4444
data-sandbox="<?php p($urlGenerator->linkTo('files_pdfviewer', 'js/pdfjs/build/pdf.sandbox.js'))?>"
45-
data-cmapurl="<?php p($urlGenerator->linkTo('files_pdfviewer', 'js/pdfjs/web/cmaps/')) ?>">
45+
data-cmapurl="<?php p($urlGenerator->linkTo('files_pdfviewer', 'js/pdfjs/web/cmaps/')) ?>"
46+
data-imageresourcespath="<?php p($urlGenerator->linkTo('files_pdfviewer', 'js/pdfjs/web/images/')) ?>">
4647
<meta charset="utf-8">
4748
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
4849
<meta name="google" content="notranslate">

0 commit comments

Comments
 (0)