我们正在更新 Data API,以便与 YouTube 统计 Shorts 短视频观看次数的方式保持一致。
了解详情
Thumbnails
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
thumbnail
资源用于标识与资源关联的不同缩略图尺寸。请注意缩略图的以下特征:
- 资源的
snippet.thumbnails
属性是一个对象,用于标识可用于相应资源的缩略图。 thumbnail
资源包含一系列对象。每个对象(default
、medium
、high
等)的名称都表示缩略图图片大小。- 不同类型的资源可能支持不同大小的缩略图。
- 不同类型的资源可能会为名称相同的缩略图定义不同的大小。例如,
video
资源的 default
缩略图通常为 120x90 像素,而 channel
资源的 default
缩略图通常为 88x88 像素。 - 对于某些图片,即使资源类型相同,缩略图图片尺寸也可能不同,具体取决于原始图片的分辨率或上传到 YouTube 的内容。例如,高清视频可能支持比非高清视频分辨率更高的缩略图。
- 每个包含缩略图大小信息的对象都具有
width
属性和 height
属性。不过,系统可能不会返回相应图片的宽度和高度属性。 - 如果上传的缩略图不符合所需的尺寸,系统会调整图片大小以符合正确的尺寸,但不会更改其宽高比。图片未被裁剪,但可能包含黑边,以便尺寸正确。
方法
该 API 支持以下针对 thumbnails
资源的方法:
- set
- 向 YouTube 上传自定义视频缩略图并为视频设置该缩略图。
资源表示法
以下 JSON 结构显示了 thumbnails
资源的格式:
{
"default": {
"url": string,
"width": unsigned integer,
"height": unsigned integer
},
"medium": {
"url": string,
"width": unsigned integer,
"height": unsigned integer
},
"high": {
"url": string,
"width": unsigned integer,
"height": unsigned integer
},
"standard": {
"url": string,
"width": unsigned integer,
"height": unsigned integer
},
"maxres": {
"url": string,
"width": unsigned integer,
"height": unsigned integer
}
}
属性
下表定义了此资源中显示的属性:
属性 |
default |
object
默认缩略图。视频(或引用视频的资源,例如播放列表项或搜索结果)的默认缩略图宽度为 120 像素,高度为 90 像素。频道的默认缩略图尺寸为 88 像素(宽)x 88 像素(高)。 |
default.url |
string
图片的网址。 |
default.width |
unsigned integer
图片的宽度。 |
default.height |
unsigned integer
图片的高度。 |
medium |
object
缩略图的更高分辨率版本。对于视频(或引用视频的资源),此图片的宽度为 320 像素,高度为 180 像素。对于频道,此图片的宽度和高度均为 240 像素。 |
medium.url |
string
图片的网址。 |
medium.width |
unsigned integer
图片的宽度。 |
medium.height |
unsigned integer
图片的高度。 |
high |
object
缩略图的高分辨率版本。对于视频(或引用视频的资源),此图片的宽度为 480 像素,高度为 360 像素。对于频道,此图片的宽度和高度均为 800 像素。 |
high.url |
string
图片的网址。 |
high.width |
unsigned integer
图片的宽度。 |
high.height |
unsigned integer
图片的高度。 |
standard |
object
比 high 分辨率的缩略图分辨率更高。此图片适用于某些视频以及引用视频的其他资源,例如播放列表项或搜索结果。此图片的宽度为 640 像素,高度为 480 像素。 |
standard.url |
string
图片的网址。 |
standard.width |
unsigned integer
图片的宽度。 |
standard.height |
unsigned integer
图片的高度。 |
maxres |
object
缩略图的最高分辨率版本。此图片尺寸适用于某些视频以及引用视频的其他资源,例如播放列表项或搜索结果。此图片的宽度为 1280 像素,高度为 720 像素。 |
maxres.url |
string
图片的网址。 |
maxres.width |
unsigned integer
图片的宽度。 |
maxres.height |
unsigned integer
图片的高度。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):2025-08-21。"],[[["\u003cp\u003eA resource's \u003ccode\u003esnippet.thumbnails\u003c/code\u003e property contains an object, and each of these objects has properties such as \u003ccode\u003edefault\u003c/code\u003e, \u003ccode\u003emedium\u003c/code\u003e, and \u003ccode\u003ehigh\u003c/code\u003e, which identify the different available thumbnail image sizes for that specific resource.\u003c/p\u003e\n"],["\u003cp\u003eThumbnail image sizes can vary significantly between different resource types (e.g., videos vs. channels), and even among resources of the same type, based on the resolution of the original uploaded content.\u003c/p\u003e\n"],["\u003cp\u003eEach thumbnail image size object contains a \u003ccode\u003eurl\u003c/code\u003e, \u003ccode\u003ewidth\u003c/code\u003e, and \u003ccode\u003eheight\u003c/code\u003e property, but the width and height may not always be returned.\u003c/p\u003e\n"],["\u003cp\u003eWhen a custom thumbnail image is uploaded, it's resized to match the required dimensions without changing its aspect ratio, which may result in black bars being added.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ethumbnails\u003c/code\u003e resource offers various image size options, such as \u003ccode\u003edefault\u003c/code\u003e, \u003ccode\u003emedium\u003c/code\u003e, \u003ccode\u003ehigh\u003c/code\u003e, \u003ccode\u003estandard\u003c/code\u003e, and \u003ccode\u003emaxres\u003c/code\u003e, each with distinct resolutions to accommodate different display needs.\u003c/p\u003e\n"]]],["Thumbnail resources define various image sizes (`default`, `medium`, `high`, etc.) for different resource types. Image dimensions vary by resource type and resolution. The `thumbnails` resource is an object within `snippet.thumbnails` that holds size-specific objects, each with `url`, `width`, and `height` properties. The `set` method allows uploading a custom video thumbnail. When the dimensions don't match, the image is resized, maintaining its aspect ratio, with possible added black bars.\n"],null,["# Thumbnails\n\nA **thumbnail** resource identifies different thumbnail image sizes associated with a resource. Please note the following characteristics of thumbnail images:\n\n- A resource's `snippet.thumbnails` property is an object that identifies the thumbnail images available for that resource.\n- A `thumbnail` resource contains a series of objects. The name of each object (`default`, `medium`, `high`, etc.) refers to the thumbnail image size.\n- Different types of resources may support different thumbnail image sizes.\n- Different types of resources may define different sizes for thumbnail images with the same name. For example, the `default` thumbnail image for a `video` resource is typically 120px by 90px, and the `default` thumbnail image for a `channel` resource is typically 88px by 88px.\n- Resources of the same type may still have different thumbnail image sizes for certain images depending on the resolution of the original image or content uploaded to YouTube. For example, an HD video may support higher resolution thumbnails than non-HD videos.\n- Each object that contains information about a thumbnail image size has a `width` property and a `height` property. However, the width and height properties may not be returned for that image.\n- If an uploaded thumbnail image does not match the required dimensions, the image is resized to match the correct size without changing its aspect ratio. The image is not cropped, but may include black bars so that the size is correct.\n\n\u003cbr /\u003e\n\nMethods\n-------\n\nThe API supports the following methods for `thumbnails` resources:\n\n[set](/youtube/v3/docs/thumbnails/set)\n: Uploads a custom video thumbnail to YouTube and sets it for a video.\n\nResource representation\n-----------------------\n\nThe following JSON structure shows the format of a `thumbnails` resource: \n\n```text\n{\n \"default\": {\n \"url\": string,\n \"width\": unsigned integer,\n \"height\": unsigned integer\n },\n \"medium\": {\n \"url\": string,\n \"width\": unsigned integer,\n \"height\": unsigned integer\n },\n \"high\": {\n \"url\": string,\n \"width\": unsigned integer,\n \"height\": unsigned integer\n },\n \"standard\": {\n \"url\": string,\n \"width\": unsigned integer,\n \"height\": unsigned integer\n },\n \"maxres\": {\n \"url\": string,\n \"width\": unsigned integer,\n \"height\": unsigned integer\n }\n}\n```\n\n### Properties\n\nThe following table defines the properties that appear in this resource:\n\n| Properties ||\n|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `default` | `object` The default thumbnail image. The default thumbnail for a video -- or a resource that refers to a video, such as a playlist item or search result -- is 120px wide and 90px tall. The default thumbnail for a channel is 88px wide and 88px tall. |\n| default.`url` | `string` The image's URL. |\n| default.`width` | `unsigned integer` The image's width. |\n| default.`height` | `unsigned integer` The image's height. |\n| `medium` | `object` A higher resolution version of the thumbnail image. For a video (or a resource that refers to a video), this image is 320px wide and 180px tall. For a channel, this image is 240px wide and 240px tall. |\n| medium.`url` | `string` The image's URL. |\n| medium.`width` | `unsigned integer` The image's width. |\n| medium.`height` | `unsigned integer` The image's height. |\n| `high` | `object` A high resolution version of the thumbnail image. For a video (or a resource that refers to a video), this image is 480px wide and 360px tall. For a channel, this image is 800px wide and 800px tall. |\n| high.`url` | `string` The image's URL. |\n| high.`width` | `unsigned integer` The image's width. |\n| high.`height` | `unsigned integer` The image's height. |\n| `standard` | `object` An even higher resolution version of the thumbnail image than the `high` resolution image. This image is available for some videos and other resources that refer to videos, like playlist items or search results. This image is 640px wide and 480px tall. |\n| standard.`url` | `string` The image's URL. |\n| standard.`width` | `unsigned integer` The image's width. |\n| standard.`height` | `unsigned integer` The image's height. |\n| `maxres` | `object` The highest resolution version of the thumbnail image. This image size is available for some videos and other resources that refer to videos, like playlist items or search results. This image is 1280px wide and 720px tall. |\n| maxres.`url` | `string` The image's URL. |\n| maxres.`width` | `unsigned integer` The image's width. |\n| maxres.`height` | `unsigned integer` The image's height. |"]]