So my wiki used to have the option of displaying unique background images and CSS stylings but I've recently had to look for new methods of implementing it after a MediaWiki update disabled the method I was using before (which was HTML tags). Recently, we got something very basic working that just the changes the background color for certain groups of pages, but the background-image tag does not appear to load correctly. As a matter of fact, it actually disables all other elements. We devised a workaround of just overlaying an image to act as a fake background, but I'm hoping to find a more elegant solution.
tl;dr I'd like some assistance in trying to figure out how to get the background-image option to work on multiple pages.
Long version:
MediaWiki: 1.34.1
PHP: 7.3.14 (litespeed)
MySQL: 5.6.44-cll-lve
ICU: 63.1
Lua: 5.1.5
The goal is to have it so that pages based on categories (determined by a template on each page that automatically adds a category) change background images and CSS stylings on a per page basis.
Here is a link to my wiki: http://omniversenexus.net/wiki/Main_Page
On the sidebar are "settings" themed after different genres. Depending on what "setting" a page is part of, the background image and link colors change.
Here are some examples of differently colored pages:
http://omniversenexus.net/wiki/Galactic_Crucibles
http://omniversenexus.net/wiki/Infinite_Histories
http://omniversenexus.net/wiki/Dreamwalkers
The respective templates that control these pages' appearances can be found here:
http://omniversenexus.net/wiki/Template:Galactic_Crucibles
http://omniversenexus.net/wiki/Template:Infinite_Histories
http://omniversenexus.net/wiki/Template:Dreamwalkers
And lastly, here's an experimental page that attempts to use the template's code on its own CSS page. There's only one of these so far:
http://omniversenexus.net/wiki/MediaWiki:GC.css
Things I've looked in to:
While searching for help, I came across this on the Extension:CSS page:
"Using the parser function to use the CSS from another page does not work to change the color or background of the page, however, using the parser function on a single page by itself does allow the background to be changed. To overcome this problem, it is possible to load the CSS through transclusion, which does not cause the problem of failing to load the change to the page background."
However, I'm not sure I follow what exactly this means.
---
In the Template Styles Extension, there's a parameter called $wgTemplateStylesAllowedUrls. A default is given as follows:
"audio" => [
"<^https://upload\\.wikimedia\\.org/wikipedia/commons/>"
],
"image" => [
"<^https://upload\\.wikimedia\\.org/wikipedia/commons/>"
],
"svg" => [
"<^https://upload\\.wikimedia\\.org/wikipedia/commons/[^?#]*\\.svg(?:[?#]|$)>"
],
"font" => [],
"namespace" => [
"<.>"
],
"css" => []
]
However, replacing the URLs with that of my own site had no noticeable effect and the background-image option still wasn't working. The result was the following error:
'Page MediaWiki:GC.css must have content model "Sanitized CSS" for TemplateStyles (current model is "CSS").'
This occurs on this particular edit revision of the Galactic Crucibles template:
http://omniversenexus.net/wiki/index.php?title=Template:Galactic_Crucibles&direction=prev&oldid=9251
I'm not 100% sure if my syntax is correct so a possible example would be appreciated.
Also, please let me know if there's anything I need to clarify or if you have further questions about what we're trying to do here.