xref: /plugin/pagesicon/DOKU_EN (revision a3ea184d8fbbe3d7b0907bb9f539dee5a6e56ad6)
1b603bbe1SLORTET====== Pagesicon Plugin ======
2b603bbe1SLORTET
3b603bbe1SLORTET---- plugin ----
4b603bbe1SLORTETdescription: Manage and expose page and media icons
5b603bbe1SLORTETauthor     : Valentin LORTET
6b603bbe1SLORTETemail      : contact@valentinlortet.fr
7b603bbe1SLORTETtype       : Action, Helper
8*a3ea184dSLORTETlastupdate : 2026-03-12
9b603bbe1SLORTETcompatible : Librarian
10b603bbe1SLORTETdepends    :
11b603bbe1SLORTETconflicts  :
12b603bbe1SLORTETsimilar    :
13b603bbe1SLORTETtags       : Media, UI, Navigation, Helper, Icons
14b603bbe1SLORTET
15b603bbe1SLORTETdownloadurl: https://github.com/Lortet/dokuwiki-plugin-pagesicon/zipball/master
16b603bbe1SLORTETbugtracker : https://github.com/Lortet/dokuwiki-plugin-pagesicon/issues
17b603bbe1SLORTETsourcerepo : https://github.com/Lortet/dokuwiki-plugin-pagesicon/
18b603bbe1SLORTETdonationurl:
19b603bbe1SLORTETscreenshot_img :
20b603bbe1SLORTET----
21b603bbe1SLORTET
22b603bbe1SLORTET===== Installation =====
23b603bbe1SLORTET
24b603bbe1SLORTETInstall the plugin from the [[plugin:extension|Extension Manager]] using the URL above, or copy it into ''lib/plugins/pagesicon''.
25b603bbe1SLORTET
26b603bbe1SLORTET===== Description =====
27b603bbe1SLORTET
28b603bbe1SLORTETThe **pagesicon** plugin can:
29b603bbe1SLORTET  * display an icon at the top of the page;
30b603bbe1SLORTET  * use this icon as the page favicon;
31b603bbe1SLORTET  * manage icons from the page action ''?do=pagesicon'';
32b603bbe1SLORTET  * handle two variants: ''big'' and ''small'';
33b603bbe1SLORTET  * expose a helper API for other plugins.
34b603bbe1SLORTET
35b603bbe1SLORTETThe plugin works on the current page. There is no external target to fill in on the management screen.
36b603bbe1SLORTET
37b603bbe1SLORTET===== Settings =====
38b603bbe1SLORTET
39b603bbe1SLORTET^ Name ^ Description ^ Default value ^
40b603bbe1SLORTET| icon_name | Candidate names for the ''big'' icon (separated by '';''). Supports ''~pagename~''. | ''~pagename~;icon_thumbnail;icon'' |
41b603bbe1SLORTET| icon_thumbnail_name | Candidate names for the ''small'' icon (separated by '';''). Supports ''~pagename~''. | ''~pagename~;icon'' |
42b603bbe1SLORTET| default_image | Default image (mediaID), used only when a helper method explicitly asks for a fallback. | '''' |
43b603bbe1SLORTET| icon_size | Size of the icon displayed at the top of the page (px). | ''55'' |
44b603bbe1SLORTET| extensions | Allowed image extensions (separated by '';''). | ''svg;png;jpg;jpeg'' |
45b603bbe1SLORTET| show_on_top | Show the icon at the top of the page. | ''true'' |
46b603bbe1SLORTET| show_as_favicon | Use the icon as favicon. | ''true'' |
47*a3ea184dSLORTET| parent_fallback | Fallback inheritance policy when the page has no icon: none, direct parent, or first icon found while walking up parent namespaces. | ''none'' |
48b603bbe1SLORTET
49b603bbe1SLORTET===== Usage =====
50b603bbe1SLORTET
51b603bbe1SLORTETFrom a page, use the **Manage icon** action, then:
52b603bbe1SLORTET  * upload a ''big'' icon;
53b603bbe1SLORTET  * upload a ''small'' icon;
54b603bbe1SLORTET  * delete the current icon.
55b603bbe1SLORTET
56b603bbe1SLORTETThe form:
57b603bbe1SLORTET  * computes the allowed target filenames from the configuration;
58b603bbe1SLORTET  * limits uploads to the configured extensions;
59b603bbe1SLORTET  * opens the media manager on the page namespace.
60b603bbe1SLORTET
61b603bbe1SLORTET===== Helper API =====
62b603bbe1SLORTET
63b603bbe1SLORTETLoad helper:
64b603bbe1SLORTET''$pagesicon = plugin_load('helper', 'pagesicon');''
65b603bbe1SLORTET
66b603bbe1SLORTET==== Main methods ====
67b603bbe1SLORTET
68b603bbe1SLORTET^ Method ^ Since ^ Description ^
69b603bbe1SLORTET| ''getPageIconId($namespace, $pageID, $size = "bigorsmall")'' | ''2026-03-09'' | Returns the mediaID of a page icon, or ''false''. |
70b603bbe1SLORTET| ''getMediaIconId($mediaID, $size = "bigorsmall")'' | ''2026-03-09'' | Returns the mediaID of the icon associated with a media file, or ''false''. |
71b603bbe1SLORTET| ''getPageIconUrl($namespace, $pageID, $size = "bigorsmall", $params = ['width' => 55], &$mtime = null, $withDefault = false)'' | ''2026-03-09'' | Returns the versioned URL of a page icon, or ''false''. |
72b603bbe1SLORTET| ''getMediaIconUrl($mediaID, $size = "bigorsmall", $params = ['width' => 55], &$mtime = null, $withDefault = false)'' | ''2026-03-09'' | Returns the versioned URL of the icon associated with a media file, or ''false''. |
73b603bbe1SLORTET| ''getDefaultIconUrl($params = ['width' => 55], &$mtime = null)'' | ''2026-03-09'' | Returns the default image to use when no icon is found. |
74b603bbe1SLORTET| ''getUploadIconPage($targetPage = "")'' | ''2026-03-06'' | Returns the ''?do=pagesicon'' URL for a page, or ''null'' when unauthorized. |
75b603bbe1SLORTET| ''getUploadMediaIconPage($mediaID = "")'' | ''2026-03-06'' | Returns the icon management URL associated with a media file. |
76b603bbe1SLORTET| ''notifyIconUpdated($targetPage, $action = "update", $mediaID = "")'' | ''2026-03-06'' | Triggers the cache invalidation event. |
77b603bbe1SLORTET| ''isPageIconMedia($mediaID)'' | ''2026-03-11'' | Tells whether a media file should be considered an icon managed by the plugin. |
78b603bbe1SLORTET
79b603bbe1SLORTET==== Public utility methods ====
80b603bbe1SLORTET
81b603bbe1SLORTETThese methods are a bit more technical, but useful when another plugin wants to reuse the exact naming and configuration logic of ''pagesicon''.
82b603bbe1SLORTET
83b603bbe1SLORTET^ Method ^ Since ^ Description ^
84b603bbe1SLORTET| ''getConfiguredExtensions()'' | ''2026-03-11'' | Returns the configured list of allowed extensions. |
85b603bbe1SLORTET| ''getVariantTemplates($variant)'' | ''2026-03-11'' | Returns the configured filename templates for ''big'' or ''small''. |
86b603bbe1SLORTET| ''normalizeIconBaseName($name)'' | ''2026-03-11'' | Normalizes an icon filename without namespace or extension. |
87b603bbe1SLORTET| ''getUploadNameChoices($targetPage, $variant)'' | ''2026-03-11'' | Returns the allowed target names for an upload. |
88b603bbe1SLORTET
89b603bbe1SLORTET===== Event =====
90b603bbe1SLORTET
91b603bbe1SLORTETOn upload or deletion, the plugin emits:
92b603bbe1SLORTET  * ''PLUGIN_PAGESICON_UPDATED''
93b603bbe1SLORTET
94b603bbe1SLORTETPayload:
95b603bbe1SLORTET  * ''target_page''
96b603bbe1SLORTET  * ''action''
97b603bbe1SLORTET  * ''media_id''
98b603bbe1SLORTET
99b603bbe1SLORTETConsumer plugins remain responsible for their own cache invalidation.
100b603bbe1SLORTET
101b603bbe1SLORTET===== Compatibility =====
102b603bbe1SLORTET
103b603bbe1SLORTETOlder API signatures are still available through legacy aliases.
104b603bbe1SLORTET
105b603bbe1SLORTET^ Historical alias ^ Added ^ Deprecated ^ Replacement ^
106b603bbe1SLORTET| ''getPageImage(...)'' | ''2026-03-06'' | ''2026-03-09'' | ''getPageIconId(...)'' |
107b603bbe1SLORTET| ''getMediaImage(...)'' | ''2026-03-06'' | ''2026-03-09'' | ''getMediaIconId(...)'' |
108b603bbe1SLORTET| ''getImageIcon(...)'' | ''2026-03-06'' | ''2026-03-09'' | ''getPageIconUrl(...)'' |
109b603bbe1SLORTET| ''getMediaIcon(...)'' | ''2026-03-06'' | ''2026-03-09'' | ''getMediaIconUrl(...)'' |
110b603bbe1SLORTET| ''getDefaultImageIcon(...)'' | ''2026-03-09'' | ''2026-03-09'' | ''getDefaultIconUrl(...)'' |
111b603bbe1SLORTET
112b603bbe1SLORTET===== How it works =====
113b603bbe1SLORTET
114b603bbe1SLORTETIcon resolution follows the configured order:
115b603bbe1SLORTET  * configured names for the requested variant;
116b603bbe1SLORTET  * ''~pagename~'' replacements;
117b603bbe1SLORTET  * historical plugin fallbacks such as ''logo'' and ''thumbnail''.
118b603bbe1SLORTET
119*a3ea184dSLORTETIf no icon is found on the page itself, the plugin can also inherit:
120*a3ea184dSLORTET  * no icon;
121*a3ea184dSLORTET  * the direct parent icon;
122*a3ea184dSLORTET  * the first icon found while walking up parent namespaces.
123*a3ea184dSLORTET
124b603bbe1SLORTETThe URLs returned by the helper are versioned with a ''pi_ts'' parameter based on the media ''filemtime''.
125b603bbe1SLORTET
126b603bbe1SLORTET===== Notes =====
127b603bbe1SLORTET
128b603bbe1SLORTET  * The plugin ignores technical pages such as ''sidebar'' and ''footer'' during icon/favicon injection, to avoid a layout include replacing the current page icon.
129b603bbe1SLORTET  * The management screen uses the current plugin configuration. If a required configuration is empty or invalid, the plugin emits a PHP warning and does not invent fallback values.
130