Extension:WikidataPageBanner/zh

WikidataPageBanner扩展将会在指定名字空间里的每一页上添加全页横幅.

全页横幅广泛用于维基导游项目. 此扩展主要受维基导游的Template:pagebanner启发.

用法
该扩展会在指定名字空间页面上自动添加横幅图像. 若要使用自定义横幅图像，请使用：   with a set of parameters explained below. 如果维基已连接到维基数据，则它也可以从那里获取横幅.

所需模板
Template:PAGEBANNER必须存在. 但可以是空的. Wikivoyage has an example of a complex Template:PAGEBANNER with rendering logic and additional template dependencies.

Parameters to the function
 解析器功能支持以下参数：
 * pgname - 在横幅里添加自定义标题
 * To add custom icons, add the parameter icon-icon_name=&lt;Article about icon> to  . Then define a background-image on .oo-ui-icon-icon_name, in Mediawiki:Common.css to use as the icon. Do this for any no. of icons to add to the page.
 * tooltip - Use tooltip=image-caption to show image description on hovering over image.
 * toc - Use toc=yes to enable a Table Of Contents within banner.
 * bottomtoc - Use bottomtoc=yes to push Table Of Contents below banner. This will affect only the page on which its used. To set site-wide toc at bottom, see Styling below.
 * extraClass - Use extraClass=name_of_css_classes(separated by space) to add additional classes to banners which can be used to customize it using styles in MediaWiki:Common.css
 * origin - (see below)

origin 参数
Use this parameter to define a suggested focal area of the image. This is used to crop the banner appropriately on small screens. The value of the parameter should consist of an x and a y coordinate separated by a comma. Each coordinate represents the distance from the center of the image as a value from -1 to 1. For example, origin=1,1 is the top left corner and origin=-1,1 is the bottom left corner. 更多有关信息，请参见此图形.

Note, as currently implemented, the origin parameter is meant for images that are much larger than the target banner (e.g. panoramas or portrait photos). It will not reposition banners where the repositioning leads to empty whitespace within the banner space. For example, if the banner is being rendered at 320px width and 180px height, an image that is also 320px and 180px cannot be repositioned at all; an image that is 600px width by 180px height can be repositioned horizontally and an image that is 320px width and 1000px height can be repositioned vertically.

必需参数
$wgWPBImage is used to set the default banner image to be used. Add image name without prefixing 'File:' namespace.

$wgWPBBannerProperty (Essential if Wikidata is enabled) - Banner property on wikidata which holds commons media file

To see default banners on pages even without the use of, set $wgWPBEnableDefaultBanner to true

可选参数
$wgWPBNamespaces array of namespaces on which to display the banner. 默认值为主名字空间. It can also be set to true, in which case it'll enable banner on all Namespaces, except those excluded by $wgWPBDisabledNamespaces.

$wgWPBDisabledNamespaces excludes certain namespaces from showing banner.

Otherwise, this parameter is disregarded and only namespaces in $wgWPBNamespaces are considered.

$wgWPBStandardSizes is an array of standard predefined screen widths in increasing order of size.

$wgWPBEnablePageImagesBannerswhen set to true and is installed will use a page image when no Wikidata image or locally defined image is set.

Examples
A few use examples with explanation:

Will add a banner using image Grand_canyon.jpg as source locally or from wikimedia commons.

Will add a banner using image Grand_canyon.jpg as source locally or from wikimedia commons. Additionally will add icons with class names oo-ui-icon-star, oo-ui-icon-unesco. Set background-image property on theses classes in Mediawiki:Common.css to your desired icon.

Will add a banner using image Grand_canyon.jpg as source locally or from Wikimedia Commons. Additionally adds a Table of Contents inside banner. Sets the name displayed on banner as Some page.

This will add a banner using the Grand_canyon.jpg image as source either locally or from Wikimedia Commons. It additionally adds CSS classes class1 and class2 to the .wpb-topbanner div.

Example usage for banner from wikidata
Make sure $wgWPBBannerProperty is set to correct wikidata banner property. Just use

Will add a banner trying to fetch banner image from wikidata property specified above if exists. If it does not exist, tries to add a default banner only if $wgWPBImage is set.

Styling
The extension has ample scope of styling the banner from Mediawiki:Common.css For example, putting the codes given below in Mediawiki:Common.css would result as explained below:

This would set the toc to appear just below the banner in case its long. Note that doing this would cause every page on wiki to have toc at bottom. However using bottomtoc=yes as a paramter would only show toc at the bottom on the page its used.

Would set the font size of Banner Name as 1em.

Would reduce the vertcial spacing between lines of Table of contents

Would set some blank space between banner and toc.