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