显示文章的缩略图。

  • 名称: core/post-featured-image
  • 类别: 主题
  • API 版本: 3
  • 块类型: 动态(服务器渲染)

属性

通过 block.json 中的 attributes 属性定义。

属性类型默认值描述
isLinkbooleanfalse角色: content
aspectRatiostring——
widthstring——
heightstring——
scalestring"cover"—
sizeSlugstring——
relstring""HTML 属性: rel。 角色: content
linkTargetstring"_self"角色: content
overlayColorstring——
customOverlayColorstring——
dimRationumber0—
gradientstring——
customGradientstring——
useFirstImageFromPostbooleanfalse—

支持功能

通过 block.json 中的 supports 属性定义。

上下文

通过 block.json 中的 usesContext 和 providesContext 属性定义。

使用的上下文:

  • postId
  • postType
  • queryId

CSS 选择器

通过 block.json 中的 selectors 属性定义。

  • 尺寸: .wp-block-post-featured-image img
  • 边框: .wp-block-post-featured-image img, .wp-block-post-featured-image .block-editor-media-placeholder, .wp-block-post-featured-image .wp-block-post-featured-image__overlay
  • 阴影: .wp-block-post-featured-image img, .wp-block-post-featured-image .components-placeholder
  • 滤镜:
    • 双色: .wp-block-post-featured-image img, .wp-block-post-featured-image .wp-block-post-featured-image__placeholder, .wp-block-post-featured-image .components-placeholder__illustration, .wp-block-post-featured-image .components-placeholder::before

块标记

这是一个 动态块。它在服务器上渲染,不会在文章内容中保存 HTML。

在文章内容中,它存储为块注释:

<!-- wp:post-featured-image /-->

来源