在丰富的图库中显示多张图片。
块关系
允许的内部块:
– core/image
属性
通过 block.json 中的 attributes 属性定义。
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
images | array | [] | 来源: query. 选择器: .blocks-gallery-item |
ids | array | [] | — |
dynamicContent | object | — | — |
navigationButtonType | string | "icon" | 枚举: icon, text, both |
shortCodeTransforms | array | [] | — |
columns | number | — | — |
caption | rich-text | — | 来源: rich-text. 选择器: .blocks-gallery-caption. 角色: content |
imageCrop | boolean | true | — |
randomOrder | boolean | false | — |
fixedHeight | boolean | true | — |
linkTarget | string | — | — |
linkTo | string | — | — |
sizeSlug | string | "large" | — |
allowResize | boolean | false | — |
aspectRatio | string | "auto" | — |
支持
通过 block.json 中的 supports 属性定义。
anchor:truealign:truebackground:backgroundImage:truebackgroundSize:truegradient:true
html:falseunits:"px","em","rem","vh","vw"spacing:margin:truepadding:trueblockGap:{"sides":["horizontal","vertical"],"__experimentalDefault":"var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )"}
color:text:falsebackground:truegradients:true
shadow:truedimensions:minHeight:trueminWidth:true
layout:allowSwitching:falseallowInheriting:falseallowEditing:trueallowOrientation:falseallowJustification:falseallowVerticalAlignment:falseallowWrap:falseallowSizingOnChildren:truedefault:{"type":"flex"}
filter:duotone:true
interactivity:clientNavigation:true
listView:true
上下文
通过 block.json 中的 usesContext 和 providesContext 属性定义。
使用的上下文:
galleryIdpostIdpostType
提供的上下文:
allowResize→ 属性allowResizeimageCrop→ 属性imageCropfixedHeight→ 属性fixedHeightnavigationButtonType→ 属性navigationButtonType
CSS 选择器
通过块.json 中的 selectors 属性定义。
- filter:
- duotone:
.wp-block-gallery :where(img)
- duotone:
块标记
这是一个 混合块。它保存服务器在渲染期间可能增强的静态标记。
<!-- wp:gallery {"linkTo":"none","className":"columns-2"} -->
<figure
class="wp-block-gallery has-nested-images columns-default is-cropped columns-2"
>
<!-- wp:image {"id":1421,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large">
<img
src="https://sergioestevaofolio.files.wordpress.com/2016/09/cropped-img_9054-1.jpg?w=190"
alt="图像库图像"
class="wp-image-1421"
/>
</figure>
<!-- /wp:image -->
<!-- wp:image {"id":1440,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image size-large">
<img
src="https://sergioestevaofolio.files.wordpress.com/2017/09/cropped-l1001498-1.jpg?w=580"
alt="图像库图像"
class="wp-image-1440"
/>
</figure>
<!-- /wp:image -->
</figure>
<!-- /wp:gallery -->
来源
- block.json (参考)
- 源代码目录 — 浏览
edit和save源文件、index.php等。