2

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?

Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291

3 Answers3

1

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.

Sam Wilson
  • 4,402
  • 4
  • 29
  • 30
  • Ah sam, amazing buddy :) With `{{#cargo_query...}}` how would I target say the category `Aubry`? I've setup cargo now though and everything is good to go!! – Jamie Hutber Jan 21 '19 at 22:10
  • ny thoughts bud :) – Jamie Hutber Jan 24 '19 at 22:21
  • Are you adding things to the Aubry category with a template? If not, I'm not sure there's a simple way; I'd recommend including the category in a template that's used on all the relevant pages. (Sorry for slow reply.) – Sam Wilson Jan 25 '19 at 02:34
  • interesting, I have never thought about using a template. Simply right now I am, with each upload, tagging the file with a category. As seen here: http://www.gwart.co.uk/File:Sisters_of_Battle_Codex_1997_-_John_Blanche.jpg – Jamie Hutber Jan 28 '19 at 14:45
  • So in theory, with Cargo... I could maybe set up a template for each page I want to do queries on, ie `Artists` and then use these templates as galleries I believe? :O That could work – Jamie Hutber Jan 30 '19 at 15:10
  • I've updated my answer to include artist/artwork example. I'm not 100% sure this is what you're after, but I do think that Cargo can probably give you want you want. I think it depends on how much you need to use Categories for other things… although, that said, I often find that Cargo basically removes my use of categories entirely. – Sam Wilson Feb 01 '19 at 00:05
  • Thanks Sam for your help. Annoyingly I missed the bounty for everybody. In the end I went with cargo and it was what I was after. But again, just wanted to say thanks – Jamie Hutber Feb 12 '19 at 18:21
  • 1
    Oh great! Glad to hear it. No worries about the bounty; all is just imaginary internet points. :-) If you have any more questions come and chat on #mediawiki IRC if you like. – Sam Wilson Feb 13 '19 at 07:06
  • Nice sam, didn't realise there was such a thing. I've joined – Jamie Hutber Feb 13 '19 at 11:48
1

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.

Kosho-b
  • 161
  • 5
  • Hey again, I don't suppose you might have an answer for: https://stackoverflow.com/questions/54655194/how-to-use-imagemagik-in-mediawiki-to-resize-image-uploads – Jamie Hutber Feb 12 '19 at 18:20
0

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]]' )

Brian
  • 1
  • above information drawn from: https://www.mediawiki.org/wiki/Extension:Cargo/Storing_data – Brian Mar 30 '21 at 17:39