本页使用了标题或全文手工转换

Commons:文件的標題

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
This page is a translated version of a page Commons:File captions and the translation is 40% complete. Changes to the translation template, respectively the source language can be submitted through Commons:File captions and have to be approved by a translation administrator.
文件的標題

文件的標題结构化数据的一项功能(是其首个被启用的部分)。其致力于存储那些文件的简短、多语言的描述。请参见MediaWiki上的文件標題页面了解更多信息。维基共享资源也在2019年1月起启用了文件標題功能。

什么才是一个好的标题?

关于文件标题的精确准则仍有待制定。

有一些技术要求(长度限制在255个字符,并且不能包含标记),这必然使标题变得

常见问题

这与描述有何不同?

  • 标题就一定是要简单和简短。然而描述卻可以非常浩瀚的,但标题的长度限制在255个字符,不能包含标记(如Wikitext链接或HTML),也不支持外部链接。
  • 标题可以作为我们结构化数据的一部分,而描述则不能。用技术术语来说,描述是包裹在语言模板中的普通wikitext,并再次包裹在信息模板中;而标题则是Wikibase儲存庫的labels。因此,它们将可以通过API进行搜索,从而可以轻松地从文件中找到/过滤/拉取标题作为元数据。

在许多情况下,标题会与描述(甚至是文件名稱!)相似或完全相同。例如,File:Fire station Hallstatt - October 2017 - 02.jpg的英文标题为 "Hallstatt fire station in October 2017"。

相反,在Pluto-01 Stern 03 Pluto Color TXT.jpg上,有一个非常广泛的描述(858个字符,还有链接),而标题则短得多(或多或少与使用该图片的维基百科文章中的标题相同)。

我(或机器人)不能简单地将描述复制到标题中吗?

首先,标题比多數的描述都要短;它们不能包含链接、也不能包含wiki标记。

虽然有可能将描述中的短文复制到标题中,但这需要人工的詮釋。

只有那些短到不具备版权的文字才可以被复制到标题中,因为标题是在CC0("公共领域")豁免下发布的。

标题的好处是什么?

其中一个核心好处是提高了语言感知的可搜索性。传统的文件描述在维基文本中,只能通过全文搜索进行搜索,这必然会搜索整个页面内容,包括类别和许可证模板;而且不可能按语言进行搜索。由于它们可以通过API进行搜索,因此第三方重用者更容易找到并再次使用媒体和标题本身。

  • 填补信息框
  • 查询某一特定语言的缺失字幕的文件
  • 建立翻译重要文件的清单,这些文件需要为一个项目或活动提供本地化的标题。
  • ...

标题存储在哪里?

标题存储在维基共享资源,作为Wikibase的一部分(因此不作为维基文本的一部分)。它们并没有被储存在维基数据上。虽然Wikibase确实在为维基数据提供动力,但它也是部署在维基共享资源上

How can I search by caption?

Users can search for files by their MediaInfo captions just as they would search for anything else. For example, if a user uploads a picture of the Eiffel Tower, and enters ‘Tour Eiffel’ (French) and ‘Eiffel Tower’ (English) as multilingual file captions, the picture is findable by another user searching for either ‘Eiffel Tower’ or ‘Tour Eiffel’.

Why are languages X Y and Z displayed for me?

If you are a logged in user the languages displayed are the ones listed in Babel boxes on your userpage.

How can I change the appearance of captions?

You may enable the following gadgets in your preferences (under “Interface: Files and categories”):

  • To collapse the caption block and add a link to expand it when needed: Collapse Captions (main script code, additional style code)
  • To make the captions block more compact: Compact Captions (code)
  • To hide the captions completely: Hide Captions (code)

Collapse Captions and Compact Captions can be combined if desired.

See in addition section Styling below.

技术

How can I query the captions using the API?

API support is for now limited but will be improved soon.

You can retrieve captions using the wbgetentities module with the entity ID. For each file there is a Wikibase entity ID MXXXX, XXXX being the page_id. So for example, File:Pluto-01 Stern 03 Pluto Color TXT.jpg has the page ID 41837276, so the entity ID is M41837276, and you can query wbgetentities&ids=M41837276. An easy way to get the Mid is to use the API action=query&prop=info&titles=File:Pluto-01_Stern_03_Pluto_Color_TXT.jpg (the page ID is provided by the pageid field).

How can I query the captions using Lua/templates

From Lua you can access them using _SDC_Description function in Module:Information, which have template interface through {{File caption}} template.

How can I set captions at upload time?

Adding captions in the Upload Wizard.

You can already fill-in captions when uploading using the Upload Wizard. You can pre-fill a caption with URL-parameters caption and captionlang when calling the Upload Wizard via link e.g. in the context of an upload campaign.

For other upload methods, support will be added in the future − you may follow the work on different bug trackers, for Pywikibot, for the Commons Android app or for Pattypan.

How can I edit the captions using the API?

You could use the API wbsetlabel module with the Wikibase entity ID MXXXX (see the section about querying for more details).

样式

The captions form field can be styled with Cascading Style Sheets. Add the rules into your common.css file or a browser addon like Stylus Userstyles Manager or xStyle. In the latter case you should use the provided restriction to Commons domain commons.wikimedia.org.

Show caption in collapsed mode

With the gadget Collapse Captions you will in collapsed mode by default only see an empty box apart from the Expand string. The following will make the caption visible in this state (i.e. Captions in your language):

.mw-collapsible-content { display: initial !important; }
.mw-slot-header,
.wbmi-entityview-captionsPanel.mw-collapsed .mw-collapsible-content *:not(.wbmi-entityview-captions-header)
	{ display: none; }
.wbmi-entityview-captionsPanel.mw-collapsed .wbmi-entityview-captions-header	{
	display: block;
	border-bottom: none;
	margin-bottom: 0;
	padding-top: 0;
	font-style: italic;
	font-weight: normal;
}
.ltr .mw-collapsible-content .wbmi-entityview-captions-header { text-align: right; }
.rtl .mw-collapsible-content .wbmi-entityview-captions-header { text-align: left; }
.rtl .mw-collapsible-toggle { float: left; }

Notes:

  • Because of the method, how the line numbers are inserted here in the presentation, in the copy of the rules you will see every second line being empty. You can safely delete these empty lines, if you want. There is actually some indentation with a tab character, too, which is also not shown here.
    This is valid for the following rules with line numbers below, as well.
  • Line 1: In tests the part !important was necessary. This will provoke a warning here in Commons in the code editor of common.css. Maybe it could be even left out when this file is used (tested only with browser addon).
  • Line 2: This will remove the header (Structured data in your language). If you want to have it displayed instead, delete this line including the comma.
  • Lines 10–12 are for formatting of the visible caption. If you want to have the default upright, bold string, delete these lines.
  • Lines 13–14: You probably need in most cases only either of these two rules, though it doesn’t matter if you copy them both. To decide which one you usually will need look at their beginning:
    • .ltr: left-to-right writing systems like Latin script (e.g. English).
    • .rtl: right-to-left writing systems like Arabian script.
If you want to have the default string at beginning (left for ltr, right for rtl systems), delete these lines.
  • Line 15 is only needed for rtl systems. It sends the toggle for collapsing and decollapsing to the left of the page. This rule will be active also for every toggle on all other Commons pages.

Further styling just for appearance, add this below the rules from above:

.wbmi-entityview-captionsPanel.mw-collapsed .wbmi-entityview-captions-header::after { content: " …"; }
.wbmi-entityview-captionsPanel:not(.mw-collapsed) .wbmi-entityview-captions-header {
	border-bottom: none;
	text-decoration: underline;
}

Notes:

  • Line 1: If the ellipsis inside of content: " …"; is not in the usual style of your language then replace it according to your taste, but do not omit the quote signs! If the added content is on the wrong side in your writing system then replace after with before.
  • Lines 2–5 are for the caption in uncollapsed mode. If you don’t want it to be underlined then delete line 4.

More compact collapsed mode

… but not that compact like with the gadget Compact Captions

.mw-slot-header { display: none; }
.wbmi-entityview-captionsPanel:not(.mw-collapsed) .wbmi-entityview-captions-header
	{ border-bottom: none; }
.wbmi-entityview-captionsPanel {
	border: none;
	margin-top: -1.5em;
}
.wbmi-entityview-captionsPanel .wbmi-entityview-captions-header {
	margin-bottom: 0;
	padding-top: 0;
}
.wbmi-entityview-captionsPanel .wbmi-entityview-entitycontent {
	padding: 0.3em 0;
}

Notes:

  • If the block interferes with the preceding text block, then delete line 6 or at least reduce the amount of the value. margin-top: -0.5em; seems to be usable.
  • Lines 1–3 can be left out if you use the unchanged rules from above, but it does not cause harm if you add them twice, as long as you remember this in future edits.

Further styling just for appearance:

.wbmi-entityview-captions-header .wbmi-entityview-editButton { font-size: smaller; }
.ltr .wbmi-entityview-editButton { margin-left: 0.25em !important; }
.rtl .wbmi-entityview-editButton { margin-right: 0.25em !important; }
.wbmi-entityview-editButton::before { content: "("; }
.wbmi-entityview-editButton::after { content: ")"; }

Notes:

  • Lines 2–3: Read notes above for .ltr and .rtl.
  • Lines 4–5: If you do not want to have parentheses around the edit string (Edit in your language) either delete both rules or replace them with your preferred characters inside of content: "…";, but do not omit the quote signs!