[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [FIX] Pdflib: Convert PDF cover image url to local path
"Adrien Mbuya Maloba \(@adrienmaloba\) via TikiWiki-cvs" <[email protected]> Fri, 17 Jul 2026 18:43:12 +0000
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6a5a77c0c080a_3819d3b82409f@gitlab-sidekiq-low-urgency-cpu-bound-v2-fcdf6d47-bmq92.mail> |
Adrien Mbuya Maloba pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki
Commits:
ddf746f9 by Josaphat Imani at 2026-07-17T21:36:36+03:00
[FIX] Pdflib: Convert PDF cover image url to local path
---
* [FIX] Pdflib: Convert PDF cover image url to local path
---
* [FIX] Pdflib: Convert PDF cover image url to local path
---
* [FIX] Pdflib: Convert PDF cover image url to local path
See merge request tikiwiki/tiki!10551
(cherry picked from commit 6063dadb727b08e776d6404eedb91edaa85d623e)
See merge request tikiwiki/tiki!10628
(cherry picked from commit 91e6fdf8d73976dd8c834333a4398fe61ec0fe07)
See merge request tikiwiki/tiki!10746
- - - - -
1 changed file:
- lib/pdflib.php
Changes:
=====================================
lib/pdflib.php
=====================================
@@ -281,6 +281,10 @@ class PdfGenerator
$wikilib = TikiLib::lib('wiki');
//checking and getting plugin_pdf parameters if set
$pdfSettings = $this->getPDFSettings($html, $prefs, $params);
+
+ if (! empty($pdfSettings['coverpage_image_settings']) && $pdfSettings['coverpage_image_settings'] !== 'off') {
+ $pdfSettings['coverpage_image_settings'] = $this->resolveFileGalleryImageToLocalPath($pdfSettings['coverpage_image_settings']);
+ }
//Add page title with content enabled in prefs and page indiviual settings
if (($prefs['feature_page_title'] == 'y' && isset($params['page']) && $wikilib->get_page_hide_title($params['page']) == 0 && $pdfSettings['pagetitle'] != 'n') || $pdfSettings['pagetitle'] == 'y') {
$html = '<h1>' . $params['page'] . '</h1>' . $html;
@@ -937,6 +941,42 @@ class PdfGenerator
return $pageContent;
}
+ /**
+ * If the given URL points to a Tiki file gallery image, extract its file ID,
+ * resolve the local filesystem path, and return that path
+ * so mPDF can read the image directly without an HTTP round-trip.
+ * Returns the original value unchanged for any other URL or when the file is
+ * not stored locally.
+ */
+ private function resolveFileGalleryImageToLocalPath(string $url): string
+ {
+ global $base_url;
+
+ // Normalize and strip base URL so we can parse both legacy and SEFURL
+ $relative = html_entity_decode(trim($url), ENT_QUOTES);
+
+ if (! empty($base_url) && str_starts_with($relative, $base_url)) {
+ $relative = substr($relative, strlen($base_url));
+ }
+ $relative = ltrim($relative, '/');
+
+ $filegalLib = TikiLib::lib('filegal');
+
+ $fileId = (int) $filegalLib->getLinkFileId($relative);
+
+ if ($fileId > 0) {
+ $file = \Tiki\FileGallery\File::id($fileId);
+ if ($file->exists()) {
+ $wrapper = $file->getWrapper();
+ if ($wrapper->isFileLocal()) {
+ return $wrapper->getReadableFile();
+ }
+ }
+ }
+
+ return $url;
+ }
+
public function getPDFSettings($html, $prefs, $params)
{
$pdfSettings = [];
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/ddf746f9d9d6071a8196c223bcc27fdad18b84ee
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/ddf746f9d9d6071a8196c223bcc27fdad18b84ee
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs