Jump to content

通用缩略图尺寸

From mediawiki.org
This page is a translated version of the page Common thumbnail sizes and the translation is 100% complete.

MediaWiki会永久保存缩略图,因此使用大量不同的缩略图尺寸会导致缩略图占用大量存储空间。 本页面旨在协调使用通用尺寸(并作为第一步,记录现有的使用模式)。 除非另有说明,否则尺寸均指像素宽度。

请注意,这里指的是从后端请求的缩略图尺寸,而不是实际显示的尺寸。

Current standard sizes in Wikimedia production: 20px, 40px, 60px, 120px, 250px, 330px, 500px, 960px, 1280px, 1920px, 3840px
External image requests that go through PHP (such as InstantCommons or the imageinfo API) will be rounded up to the closest standard size; direct requests (hotlinking) will be rejected unless they use a standard size. (T414805)

相关配置设置

名称 描述 默认 維基媒體
$wgThumbnailSteps 用作缩略图尺寸档次的图像宽度。 不使用手动指定的尺寸;系统会显示尺寸大于请求值且步长最小的缩略图,并通过HTML属性将其缩小显示。 通过提供用户请求的稍大尺寸缩略图,它增加了向用户传输的带宽;但同时,通过对缩略图的生成与存储进行去重处理,它又能节省资源。 20, 40, 60, 120, 250, 330, 500, 960, 1280, 1920, 3840 [1]
$wgUploadThumbnailRenderMap 上传时预先渲染尺寸。 same
$wgThumbLimits In-article thumbnail sizes available as user preference. 120, 150, 180, 200, 220, 250, 300, 400 180, 250, 400 [2]
$wgDefaultUserOptions['thumbsize'] Thumbnail size used in articles when the size is not specified in the wikitext and the user has not set their preference. 5 (250px) same
$wgDefaultUserOptions['imagesize'] Image size used on file description pages when the user has not set their preference. 2 (800x600) same
$wgResponsiveImages Whether to provide alternative image sizes for high-DPI displays. When enabled, article thumbnails, galleries, and images on file pages will have an srcset with 2x of the original size. true same
$wgThumbUpright Scaling factor applied to the $wgThumbLimits value for thumbnails where the upright wikitext option is used. 0.75 (187.5px) same
$wgGalleryOptions Image sizes in galleries (when not overriden in the <gallery> tag). For traditional galleries, the imageWidth and imageHeight options are used as a bounding box to determine physical thumbnail size; for mode="packed" galleries, width is ignored and imageHeight * 1.5 is used. 120x120 same
$wgImageLimits File description page image sizes available as user preference; also used for the list of download links under the image. Values are bounding boxes. 320x240, 640x480, 800x600, 1024x768, 1280x1024, 2560x2048 same
$wgThumbnailBuckets Intermediary thumbnail sizes to use to speed up thumbnail rendering (automatically generated when the image is first thumbnailed). none 1280 [3] (not sure Thumbor uses it though)

应用场景

  • Thumbnails in articles: per above, 250px + 500px by default. For upright images, 188px + 281px + 375px by default. Common manually specified Wikipedia image sizes: 20px or 40px for icons, 23x15px for flags.
  • Galleries: On Wikimedia sites, 120px for traditional galleries. Can be anything for packed galleries as they are height-constrained.
  • Images on file description pages: 800px + 1200px + 1600px (or it could be anything if the image has smaller than 4:3 aspect ratio).
  • Images in the file history of description pages: 120x120px (whichever side is bigger)
  • Images in Galleries of Special:NewFiles, Special:Search etc, 120x120px (whichever side is bigger)
  • Image download links: 320px, 640px, 800px, 1024px, 1280px, 2560px (for most images, depending on aspect ratio, as above)
  • Codex thumbnail component: 40px
  • MediaViewer : $wgMediaViewerThumbnailBucketSizes set of width buckets: 320, 800, 1024, 1280, 1920, 2560, 2880
  • Page previews : 320px or 640px (depending on the resolution)
  • Search dropdowns:
  • VisualEditor :
    • Link preview (ve.init.mw.LinkCache): 80px
  • Wikibase : standard MediaWiki thumbnail sizes (?)
  • GrowthExperiments :
    • Impact module article icons: 40px, to match Codex thumbnail component size
    • Task cards: 260px on mobile, 332px on desktop (?)
    • Link recommendation dialog: uses ve.init.mw.LinkCache
    • Image recommendation thumbnail: uses MediaWiki thumb size on desktop, screen width capped to 500px on mobile
    • Image recommendation dialog: 120px or 160px depending on screen size
    • Image recommendation dialog, fullscreen image preview: screen size
    • Image recommendation save dialog: 226px on desktop, screen size on mobile
  • Toolhub: 40/60/80px, 50/75/100px, 100/150/200px (depending on viewport resolution)
  • To do: MobileFrontend search, mobile thumbnails (MobilePage::SMALL_IMAGE_WIDTH/TINY_IMAGE_WIDTH?), mobile image viewer, Special:Search snippets, Special:MediaSearch, probably a bunch of VisualEditor things, MediaViewer download/embed links, mobile apps; FullSearchResultWidget::THUMBNAIL_SIZE, SearchResultThumbnailProvider::THUMBNAIL_SIZE; see if any of these support srcset

常見問題解答

Q: Help, my application got a "429 Use thumbnail steps listed on https://w.wiki/GHai" message!

Make sure you're using one of the "standard" sizes referenced in $wgThumbnailSteps above. Alternatively use the imageinfo api instead of directly constructing the image's url.

参见