xref: /plugin/pagesicon/DOKU_EN.md (revision 74a9e7636f2e172c4b5990b529a0ab322717c972)
1====== Pagesicon Plugin ======
2
3---- plugin ----
4description: Manage and expose page/media icons
5author     : Lortet
6email      : valentin@lortet.io
7type       : Action, Helper
8lastupdate : 2026-03-09
9compatible : Librarian
10depends    :
11conflicts  :
12similar    :
13tags       : Media, UI, Navigation, Helper, Icons
14
15downloadurl: https://github.com/Lortet/dokuwiki-plugin-pagesicon/zipball/master
16bugtracker : https://github.com/Lortet/dokuwiki-plugin-pagesicon/issues
17sourcerepo : https://github.com/Lortet/dokuwiki-plugin-pagesicon/
18donationurl:
19screenshot_img :
20----
21
22===== Installation =====
23
24Install the plugin from the [[plugin:extension|Extension Manager]] using the source download URL above.
25
26===== Description =====
27
28The **pagesicon** plugin allows you to:
29  * display an icon at the top of the page;
30    * {{https://i.ibb.co/TBz1yVHB/Screenshot-2026-03-06-at-20-25-47-Welcome-to-your-new-Doku-Wiki-Wiki-BSPP.png?250}}
31    * {{https://i.ibb.co/XZd613sL/Screenshot-2026-03-06-at-20-25-39-Formatting-Syntax-Wiki-BSPP.png?250}}
32  * use the page icon as favicon (browser tab icon);
33  * manage the icon from the page action ''?do=pagesicon'';
34    * {{https://i.ibb.co/1JBtfvH9/Screenshot-2026-03-06-at-20-26-12-Welcome-to-your-new-Doku-Wiki-Wiki-BSPP.png?250}}
35  * expose a helper API for other plugins (e.g. catmenu, visualindex).
36    * {{https://i.ibb.co/Mkv7RY8K/Screenshot-2026-03-06-at-20-26-00-Welcome-to-your-new-Doku-Wiki-Wiki-BSPP.png?250}}
37
38===== Settings =====
39
40^ Name ^ Description ^ Default value ^
41| icon_name | Candidate names for the ''big'' icon (separated by '';''). Supports ''~pagename~''. | ''~pagename~;icon_thumbnail;icon'' |
42| icon_thumbnail_name | Candidate names for the ''small'' icon (separated by '';''). Supports ''~pagename~''. | ''~pagename~;icon'' |
43| default_image | Default image (mediaID), used when ''withDefault=true'' on URL methods. | '''' |
44| icon_size | Size of the icon displayed at the top of the page (px). | ''55'' |
45| extensions | Allowed image extensions (separated by '';''). | ''svg;png;jpg;jpeg'' |
46| show_on_top | Show icon at the top of the page. | ''true'' |
47| show_as_favicon | Use the icon as page favicon. | ''true'' |
48
49===== Usage =====
50
51From a page, use the **Manage icon** action, then:
52  * upload a ''big'' or ''small'' icon;
53  * delete the current icon.
54
55===== Helper API =====
56
57Load helper:
58''$pagesicon = plugin_load('helper', 'pagesicon');''
59
60^ Method ^ Description ^
61| ''getPageIconId($namespace, $pageID, $size = "bigorsmall")'' | Returns a mediaID (or ''false''). |
62| ''getMediaIconId($mediaID, $size = "bigorsmall")'' | Returns the media icon mediaID (or ''false''). |
63| ''getPageIconUrl($namespace, $pageID, $size = "bigorsmall", $params = ['width' => 55], &$mtime = null, $withDefault = false)'' | Returns a versioned icon URL (''pi_ts=<filemtime>'') or ''false''. |
64| ''getMediaIconUrl($mediaID, $size = "bigorsmall", $params = ['width' => 55], &$mtime = null, $withDefault = false)'' | Returns a versioned media icon URL (''pi_ts=<filemtime>'') or ''false''. |
65| ''getDefaultIconUrl($params = ['width' => 55], &$mtime = null)'' | Returns the configured default image URL, or bundled ''default_image.png''. |
66| ''getUploadIconPage($targetPage = "")'' | Returns the icon management URL (or ''null'' if unauthorized). |
67| ''getUploadMediaIconPage($mediaID = "")'' | Returns the icon management URL for a media. |
68| ''notifyIconUpdated($targetPage, $action = "update", $mediaID = "")'' | Triggers the cache invalidation event. |
69
70===== Event =====
71
72On upload/delete, the plugin emits:
73  * ''PLUGIN_PAGESICON_UPDATED''
74    * to allow cache invalidation in consumer plugins.
75
76Payload:
77  * ''target_page''
78  * ''action''
79  * ''media_id''
80
81===== Signature compatibility =====
82
83Historical signatures (before ''09-03-2025''):
84  * ''getPageImage($namespace, $pageID, $size = "bigorsmall")''
85  * ''getMediaImage($mediaID, $size = "bigorsmall")''
86  * ''getImageIcon($namespace, $pageID, $size = "bigorsmall", $params = ['width' => 55], &$mtime = null)''
87  * ''getMediaIcon($mediaID, $size = "bigorsmall", $params = ['width' => 55], &$mtime = null)''
88
89Compatibility is preserved through legacy aliases:
90  * ''getPageImage(...)'' -> ''getPageIconId(...)'' (legacy ''$withDefault'' argument is ignored)
91  * ''getMediaImage(...)'' -> ''getMediaIconId(...)'' (legacy ''$withDefault'' argument is ignored)
92  * ''getImageIcon(...)'' -> ''getPageIconUrl(...)''
93  * ''getMediaIcon(...)'' -> ''getMediaIconUrl(...)''
94  * ''getDefaultImageIcon(...)'' -> ''getDefaultIconUrl(...)''
95