MediaWiki - How to use all images from a Category in a gallery

Viewed 387

I have set a description on the file:

{{Information
  |description = A cheeky description
}}

I have tried to use this CategoryGallery successfully, but I cannot get the descriptions to work:

enter image description here

I have also used the required extra extension, they talk about short_summary, however this does not exist as far as i can see in Information template

<catgallery cat="Aubry" bpdcaption="short_summary" />

So how do I use category images in a gallery with MediaWiki?

3 Answers

If you didn't mind using a different extension, Cargo can do this pretty easily (and lots of other useful stuff as well).

In Template:Artwork do something like:

<noinclude>
{{#cargo_declare: _table = artworks
| description = Wikitext
| artist = Page
}}
</noinclude><includeonly>
{{#cargo_store: _table = artworks
| description = {{{description|}}}
| artist = {{{artist|}}}
}}
</includeonly>

; Description
: {{{description}}}
; Artist
: [[{{{artist}}}]]

And then where you want the gallery (e.g. on a page for an artist), do something like:

{{#cargo_query: tables = artworks
|fields = _pageName, description, artist
|where = artist = '{{PAGENAME}}'
|format = gallery
|caption field = description
|show filename = 0
|show dimensions = 0
|show bytes = 0
}}

This assumes that the Artwork template is used on files' pages; if you wanted a mainspace page for each artwork, you could still do something similar but would have to introduce a separate image field that points to the actual file.

Cargo may be overkill for this (you didn't mention that you are saving any metadata for all the images).

I personally uses DPL, which allows you do to some cool tricks with categories, you can check the manual, but as for your case:

{{#dpl:
category=all_photos
|mode=gallery
}}

that very simple example, but you can control the output format within the query (read at the manual i've mentioned).

DPL is built for this scenarios.

With a little prep, you should be able to use '_categories' if you have set up the wiki's cargo to store categories using "$wgCargoPageDataColumns[] = 'categories';" in the LocalSettings.php

example...

{{#cargo_query:
tables=MyTable
|where=MyTable._categories HOLDS 'Foo'
|fields=MyTable._pageName
}}

The above should give the name of the files in the category 'Foo'.

To show the images, change the fields to... |fields=CONCAT( '[[file:', MyTable._pagename, '|thumb]]' )

Related