„Dokumente“ heißt jetzt „Downloads“
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m38s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m31s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m39s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m54s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m50s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 3m18s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 3m19s
CI / Build-Artefakte aktuell (pull_request) Successful in 55s
All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 2m38s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 2m31s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m39s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m54s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 3m50s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 3m18s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 3m19s
CI / Build-Artefakte aktuell (pull_request) Successful in 55s
Der Name „Dokumente“ bleibt dem kommenden QM-Modul (QM-Dokumente und -Formulare) vorbehalten. - Plugin plugins-core/downloads (Inhaus\Plugins\Downloads), Adresse /downloads, Rechte downloads.*, Objekttyp download_folder, Block downloads.folder, Kachel downloads.favorites - Migration für bestehende Installationen: Tabellen und Spalten, Rechte, Sichtbarkeiten, Menü, Startseiten-Anordnung, Blöcke in Seiten und Fassungen, Plugin-Zustand; mit Test - Alte Links unter /dokumente leiten dauerhaft weiter Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c71131d054
commit
f78cc96be7
120 changed files with 1091 additions and 866 deletions
|
|
@ -1,47 +0,0 @@
|
|||
/**
|
||||
* Erste Seite eines PDFs als kleines Bild – im Browser mit pdf.js, damit der
|
||||
* Server (Shared Hosting) keine Bildbearbeitung braucht. pdf.js wird erst
|
||||
* geladen, wenn tatsächlich ein Vorschaubild gebraucht wird.
|
||||
*/
|
||||
const cache = new Map();
|
||||
let library = null;
|
||||
|
||||
async function pdfjs() {
|
||||
library ??= Promise.all([import('pdfjs-dist'), import('pdfjs-dist/build/pdf.worker.min.mjs?url')]).then(([lib, worker]) => {
|
||||
lib.GlobalWorkerOptions.workerSrc = worker.default;
|
||||
|
||||
return lib;
|
||||
});
|
||||
|
||||
return library;
|
||||
}
|
||||
|
||||
export function pdfThumbnail(url, width = 360) {
|
||||
if (!cache.has(url)) {
|
||||
cache.set(
|
||||
url,
|
||||
(async () => {
|
||||
const lib = await pdfjs();
|
||||
const pdf = await lib.getDocument({ url, isEvalSupported: false, enableXfa: false }).promise;
|
||||
|
||||
try {
|
||||
const page = await pdf.getPage(1);
|
||||
const viewport = page.getViewport({ scale: width / page.getViewport({ scale: 1 }).width });
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = Math.round(viewport.width);
|
||||
canvas.height = Math.round(viewport.height);
|
||||
await page.render({ canvasContext: canvas.getContext('2d'), viewport }).promise;
|
||||
|
||||
return canvas.toDataURL('image/jpeg', 0.82);
|
||||
} finally {
|
||||
pdf.destroy();
|
||||
}
|
||||
})().catch((error) => {
|
||||
cache.delete(url);
|
||||
throw error;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return cache.get(url);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue