Extension:MarkImages

The MarkImages extension marks images in galleries on special and category pages based on image's categories.

The user can specify rules for which categories should correspond to what CSS classes. The extension then adds these CSS classes to divs of corresponding images in galleries. It is intended for

Configuration
All configuration is done through a single MediaWiki message: MediaWiki:MarkImages-categories. It should contain a list of category-CSS class pairs in following format:


 * Category:Example category 1|example-class-1
 * Category:Example category 2|example-class-2|recursive

The category name should always include the "Category:" prefix in your wiki's local language (canonical). The recursive option tells the extension to apply this rule recursively to all child categories. You can specify as many rules as you like, you can also use the same CSS class multiple times and apply multiple classes to a single image.

You have to define these CSS classes yourself. You can place them for example in MediaWiki:Common.css to make it apply to all desktop skins, or in a gadget to allow your users to enable or disable this feature. The extension appends these classes to the  element with   CSS class. A simple example from Nonsensopedia of a CSS class you can use for modifying image's background:

After setting up the extension you should run the  script provided in the maintenance folder to initialize CSS class cache and see the results. The extension will automatically update the cache whenever an image's description page is changed or null-edited. It will not update the cache when you modify the configuration or change the category tree in some way. In such a case you will have to have to rerun this maintenance script or null-edit all affected pages. This should be fixed in the future elegantly, but for now one solution is to set up a cron job that runs the maintenance script at night.

How it works
TBD