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