Template:RandomGalleryAnyPage

Category:Main message boxesCategory:Lua-based templates

This template displays a random selection of images fetched exclusively from a **specified wiki page list**.

The underlying module has been updated to **only process lists** from the page specified in the first parameter; it no longer fetches images from categories.

Usage

{{RandomGalleryAnyPage|Page title (e.g., User:Example/Image List)|image height in px|number of images}}

Note: The page list must be a regular wiki page (e.g., in the User:, Project:, or main namespace) containing one image filename entry per line.

The module now supports full gallery entry syntax in your list page. Each line can contain the filename followed by a pipe and the caption, including wikitext (e.g., links):

File:Example.jpg|This is a caption with a [[Wikilink]].

Examples

{{RandomGalleryAnyPage|User:Suyash.dwivedi/My_Favorite_Images|50|12}}
{{RandomGalleryAnyPage|Project:Featured_List/Images_to_show|200|20}}

Debug Mode

To enable debug output:

{{RandomGalleryAnyPage|User:Example/List|200|12|debug=yes}}

Parameters

  • 1(Required) **Page list title** (must include namespace prefix like "User:")
  • 2 — Image height in px (default: 200)
  • 3 — Number of images (default: 12)
  • 4 — Random seed (optional, default: current timestamp)
  • debug — Set to "yes" or "1" to show debug information

---

Random Seed (`|4=` or `|seed=`)

The random seed controls the shuffling and selection order of the images. Using a fixed seed ensures that the gallery display is **stable** and remains the same across multiple page views, purges, or over time.

If no seed is provided, it defaults to `20260613214014`, which changes every second, resulting in a **highly unstable** (but freshly randomized) selection on almost every page load.

Random Seed Examples for Gallery Consistency
Seed ValueTemplate Call ExampleEffect on GalleryUse Case
(Omitted)
or `20260613214014`
{{RandomGalleryAnyPage|User:Example/List|200|12}}
Highly Unstable / Dynamic
The images will change randomly on almost every page load or purge.
You want the freshest possible random selection every time a user visits the page.
`12345`
(or any fixed number)
{{RandomGalleryAnyPage|User:Example/List|200|12|seed=12345}}
Completely Stable / Fixed
The same set of random images will always be chosen from the list.
Useful for test cases, or when you want a fixed display that never changes.
`{{#expr:({{CURRENTD}}*10) + floor({{CURRENTHOUR}}/6) }}`
{{RandomGalleryAnyPage|User:Example/List|200|12|seed={{#expr:({{CURRENTD}}*10) + floor({{CURRENTHOUR}}/6) }} }}
6-Hour Stability
The selection is stable and remains the same for 6-hour blocks (00:00, 06:00, 12:00, 18:00 UTC).
Ideal for frequently rotating content that is consistent for short periods.
`6`
{{RandomGalleryAnyPage|User:Example/List|200|12|seed={{CURRENTDOW}}}}
Daily Stability
The selection changes only once every day (at midnight UTC).
You want a gallery that remains consistent for all users throughout the day, but updates daily.
`202606`
{{RandomGalleryAnyPage|User:Example/List|200|12|seed={{CURRENTYEAR}}{{CURRENTMONTH}}}}
Monthly Stability
The selection changes only once per calendar month.
Ideal for rotating "featured" lists or seasonal content that shouldn't change too often.
`Template:RandomGalleryAnyPage`
(or any unique page title)
{{RandomGalleryAnyPage|User:Example/List|200|12|seed={{FULLPAGENAME}}}}
Page-Dependent Stability
The selection is stable and unique to the page it is placed on.
Ensures that two different pages using the same list will have a different, but permanent, random gallery.

---

Notes

  • The module fetches image files only from the content of the specified wiki page.
  • Image file entries in the list should be on separate lines.
  • Images are randomly shuffled on each page load/purge.
  • If the page is not found or is empty, an error will be displayed.
  • Filenames can start with or without "File:" prefix - both formats work.
Category:Commons templates for galleries Category:Commons Lua templates
Category:Commons Lua templates Category:Commons templates for galleries Category:Lua-based templates Category:Main message boxes