MediaWiki - 如何在图库中使用类别中的所有图像

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

我在文件上设置了描述:

{{Information
  |description = A cheeky description
}}

我已经尝试使用此 CategoryGallery 成功,但我无法使描述生效:

我也使用了所需的额外 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" />

那么如何在 MediaWiki 中使用图库中的类别图像?

如果您不介意使用不同的扩展,Cargo 可以很容易地做到这一点(以及许多其他有用的东西)。

Template:Artwork 中执行如下操作:

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

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

然后在您想要画廊的位置(例如,在艺术家的页面上),执行如下操作:

{{#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
}}

这假定在文件页面上使用了 Artwork 模板;如果你想为每个艺术作品创建一个主空间页面,你仍然可以做类似的事情,但必须引入一个单独的 image 字段来指向实际文件。

Cargo 对此可能有点矫枉过正(您没有提到要为所有图像保存任何元数据)。

我个人使用DPL, which allows you do to some cool tricks with categories, you can check the manual,但是你的情况:

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

那个非常简单的示例,但您可以在查询中控制输出格式(阅读我提到的手册)。

DPL 就是为这种情况而构建的。

如果您已经使用“$wgCargoPageDataColumns[] = 'categories';”设置了 wiki 的 cargo 来存储类别,那么通过一些准备,您应该能够使用“_categories”在 LocalSettings.php

示例...

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

以上应该给出类别'Foo'中的文件名。

要显示图像,请将字段更改为... |fields=CONCAT( '[[file:', MyTable._pagename, '|thumb]]' )