admin管理员组文章数量:1122826
I added the aspectRatio
prop to the block.json
file in a custom block that renders a grid of posts of a specific type:
{
"$schema": ".json",
"apiVersion": 3,
"name": "my/custom-post-grid",
"title": "Custom Post Grid",
"description": "Display a grid of custom posts.",
"textdomain": "mydomain",
"category": "media",
"attributes": {
"category": {
"type": "integer",
"default": 0
},
"columns": {
"type": "integer",
"default": 3
},
"gap": {
"type": "string",
"default": "10px"
}
},
"supports": {
"dimensions": {
"aspectRatio": true
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"__experimentalFontFamily": true
}
},
"editorScript": "file:./index.js",
"style": "file:./style-index.css"
}
But, I can't see the aspect ratio selector in the block sidebar:
What am I doing wrong?
I added the aspectRatio
prop to the block.json
file in a custom block that renders a grid of posts of a specific type:
{
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "my/custom-post-grid",
"title": "Custom Post Grid",
"description": "Display a grid of custom posts.",
"textdomain": "mydomain",
"category": "media",
"attributes": {
"category": {
"type": "integer",
"default": 0
},
"columns": {
"type": "integer",
"default": 3
},
"gap": {
"type": "string",
"default": "10px"
}
},
"supports": {
"dimensions": {
"aspectRatio": true
},
"spacing": {
"margin": true,
"padding": true
},
"typography": {
"fontSize": true,
"__experimentalFontFamily": true
}
},
"editorScript": "file:./index.js",
"style": "file:./style-index.css"
}
But, I can't see the aspect ratio selector in the block sidebar:
What am I doing wrong?
Share Improve this question asked Jul 12, 2024 at 7:36 leemonleemon 2,0024 gold badges22 silver badges51 bronze badges1 Answer
Reset to default 2 +50Per the developer handbook:
This value signals that a block supports some of the CSS style properties related to dimensions. When it does, the block editor will show UI controls for the user to set their values if the theme declares support.
So in your theme you'll need to declare support either by setting appearanceTools
to true
in theme.json
or the legacy way using add_theme_support( 'appearance-tools' )
in functions.php
.
本文标签: No aspect ratio selector in a custom block
版权声明:本文标题:No aspect ratio selector in a custom block 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736300864a1930974.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论