This page is a translated version of the page Extension:Popups and the translation is 59% complete.
关于the feature that is powered by this extension,参见:Page Previews
OOjs UI icon advanced-invert.svg
發布狀態: 穩定版本
Hovercard english.png
实现 皮肤
描述 在用户悬停在条目链接及腳註標記时显示弹窗
  • Prateek Saxena (user:Prtksxna),
  • Yair Rand,
  • Sam Smith,
  • Joaquín Oltra Hernández,
  • Bahodir Mansurov,
  • Jon Robson,
  • Piotr Miazga,
  • Jeff Hobson
  • WMDE Engineering
MediaWiki 1.30+
PHP 5.6+
许可协议 GNU通用公眾授權條款2.0或更新版本
示例 English Wikipedia
  • $wgPopupsVirtualPageViews
  • $wgPopupsOptInDefaultState
  • $wgPopupsRestGatewayEndpoint
  • $wgPopupsHideOptInOnPreferencesPage
  • $wgPopupsConflictingRefTooltipsGadgetName
  • $wgPopupsTextExtractsIntroOnly
  • $wgPopupsPageDisabled
  • $wgPopupsStatsvSamplingRate
  • $wgPopupsReferencePreviewsBetaFeature
  • $wgPopupsConflictingNavPopupsGadgetName
  • $wgPopupsOptInStateForNewAccounts
  • $wgPopupsGateway
  • $wgPopupsReferencePreviews
問題 尚未完成的工作 · 报告錯誤


这个扩展原始Design team的开始,因著名的Navigation popups(导航弹窗)而作。当前该功能对所有未登录的维基百科用户启用。参见页面预览以了解扩展运作的描述,以及在此维基媒体项目的更多信息。

引用预览功能最终被加入,并用于实现德语社区的愿望。帮助:参考文献预览 有更详细的介绍和更多信息。


mwApiPlain网关一起使用时,本扩展依赖于扩展:TextExtracts Extension:页面图像 。 此外还依赖测试功能 (如果您希望开启beta特性参考文献预览);此外还依赖Extension:EventLogging Extension:WikimediaEvents (对于指导)。


  • 下载文件,并将其放置在您extensions/文件夹中的Popups目录内。
  • 将下列代码放置在您的LocalSettings.php 的底部:
    wfLoadExtension( 'Popups' );
  •   完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。


wfLoadExtensions( [
] );
$wgPopupsHideOptInOnPreferencesPage = true;
$wgPopupsReferencePreviewsBetaFeature = false;

Page previews API

Every project is different, and what displays in your previews is highly dependent on the content inside your wiki.

Popups extension has been optimized to work with Wikipedia-like content (e.g. wikitext).

If your wiki is using a different kind of content handler (for example as is the case for Wikibase ) it will need to provide its own API.

The API can be written in any language, but the response of the API must match the spec defined here:


Defining new APIs is out of scope for the Popups extension.

Once defined, you can configure page previews to point to your API using $wgPopupsRestGatewayEndpoint configuration option.


选项 默认值 文档
$wgPopupsVirtualPageViews false Whether the extension should log virtual pageviews.
$wgPopupsHideOptInOnPreferencesPage false 是否应在首选项页面上隐藏启用/禁用页面预览的选项。 False 为默认值
$wgPopupsOptInDefaultState 1 老账户的页面预览可见性默认值。必须是字符串,以便与beta功能设置兼容。 有关更多信息,请参阅 task T191888 This value is internally converted to the Bool type. Therefore, a value greater than or equal to 2 has the same meaning as 1.
$wgPopupsOptInStateForNewAccounts 1 新创建帐户的默认页面预览可见性(从 2018 年第二季度开始)。 有关更多信息,请参阅 task T191888
$wgPopupsConflictingNavPopupsGadgetName 'Navigation_popups' 本地 Navigation popups gadget 名称用作 MediaWiki:Gadgets-definition 中的标识符。 此小工具与页面预览不兼容。 对于启用了小工具的用户,该扩展程序将自行禁用。
$wgPopupsConflictingRefTooltipsGadgetName ReferenceTooltips 本地 参考文献提示工具 小工具名称用作 MediaWiki:Gadgets-definition 中的标识符。 此小工具与参考预览不兼容。 对于启用了小工具的用户,参考预览将自行禁用。
$wgPopupsGateway 'mwApiPlain' 用于获取弹出窗口数据的网关。 可用选项:[mwApiPlain|restbasePlain|restbaseHTML]。 src/gateway/page.js 中提供了完整且始终最新的列表。
$wgPopupsRestGatewayEndpoint '/api/rest_v1/page/summary/' 指定摘要来源的REST端点。 端点必须符合 Specs/Summary/1.2.0 的规格。
$wgPopupsReferencePreviews true Temporary feature flag to disable reference previews during development.
$wgPopupsReferencePreviewsBetaFeature true 参考预览是否应作为Beta功能提供。如果为false,则默认情况下为所有用户启用参考预览。
$wgPopupsEventLogging false 我们是否应该记录事件。 请注意,如果在不使用的情况下启用此功能,则将为所有用户记录变量事件而不进行任何采样! 小心!
$wgPopupsStatsvSamplingRate 0 将性能数据记录到 statsv 的采样率。
$wgPopupsPageDisabled Several special pages. See extension.json for the full list. 不应显示弹出窗口的页面列表。 包含子页面。 这些页面受 wiki 的 HTML 缓存策略的约束。 可能需要清除这些页面才能查看此配置变量的效果。 每个排除的页面都应由规范名称定义,例如:Special:Userlogin




图片来源于Extension:页面图像 ,该图片返回与文章相关的单个最合适的缩略图。 它忽略维护模板,小作品,旗帜图标等。



您也可以使用扩展:TextExtracts 扩展。 这个扩展有各种警告,我们不积极支持使用这个API。





The reference types displayed are set by using specific CSS-classes on the ‎<cite> tag that can be used to encapsulate the content of a reference, e.g. <ref><cite class="journal"></cite></ref>. Currently the following types are supported: web, journal, book, news, note. Apart from that there is always a generic fallback if neither the cite tag was found nor an appropriate class was used. Please note, that it's not recommended to use the CSS-classes directly in wikitext, but rather by creating templates.


This extensions currently has only one renderer, that is for ordinary pages.

New renderers for different kind of pages, or things like references can be easily added.

One needs to create a new object with the following methods:

  • init
  • createPopup
  • getOffset
  • getClasses
  • processPopup

You can see details of these methods in ext.popups.renderer.article.js or this patch that adds a renderer for references.


  • Users of the Translate extension should note that Page Previews requests previews in the content language of the page. If the preview contains a complete translatable block, then it will be translated. If, however, the preview contains an incomplete translateable block – because a sentence is cut off, say – then it isn't translated and will be displayed in the content language of the page. If you are observing this behavior, then you should consider marking up individual sentences in your lead section. T167852 is for a technical audience but has more information on the underlying problem.
  • Longer math formulas cutting off in preview - long math or chemical formulas (formulas wider than the preview width) display as truncated in previews. We were not able to add a gradient in order to indicate that the formula is continued on the article itself.
  • Small files may be in the "Рage information" (action=info), but not in the "Popups". Some requirements are set here - for a portrait image: exact (min) height 250 px & max width 203 px; for a landscape image: exact (min) width 320 px & max height 200 px[1]. To display, images must be able to become a thumbnail that is larger or equal to these "exact" sizes. (If you are cropping a large image to make a leading picture for an article, be sure that the picture you are creating is not smaller than the specified sizes.)


Why can't I copy and paste text from a preview?

At time of writing, the cons of doing so outweigh the pros. Essentially it boils down to decreasing the touch area to read the article in full. Once Page Previews is deployed on English and German Wikipedia, feel free to reopen this task and reignite the discussion, but right now we have no plans.

How can I change the image that I see on preview?


Any element marked with the noexcerpt class will be stripped from the summary.


These are provided by the summary REST API or the TextExtracts API in case your wiki is using the default mwApiPlain gateway.

Why are parenthetical stripped?

There's a good discussion going on in T91344 in Phabricator. If you have any views on this or see any problems relating to this, please let us know there.

Why don't I see Popups outside of content namespaces?

Popups appear on links to pages in content namespaces only. This is a limitation of Popups; TextExtracts are available from other namespaces. You may work around this by appending more namespaces into $wgContentNamespaces .