图库块重构 Gutenberg Wordpress
根据下面的开发说明:
https: //make.wordpress.org/core/2021/08/20/gallery-block-refactor-dev-note/
古腾堡画廊块的 HTML 结构已从 UL 更改> LI至图>数字。没关系,但现在,我们不像以前那样在每个画廊项目上都有 CSS 类,我知道通过 CSS 选择该画廊上的子元素不是问题,但问题是当我们必须使用块钩子 render_block 通过 PHP 对块结构进行一些更改,我通过使用其类名称来选择图库项目,但现在这是不可能的。这里有人面临同样的问题吗?
according to the dev note bellow:
https://make.wordpress.org/core/2021/08/20/gallery-block-refactor-dev-note/
the HTML structure of the Gutenberg gallery block has been changed from a UL > LI to FIGURE > FIGURE. That is okay, but now, we don't have a CSS class on each gallery item as we had before, I know that via CSS this is not a problem to select child elements on this gallery, but the problem is when we have to make some changes into the block structure via PHP using the block hook render_block, I was selecting gallery items by using its classes names, and now, this is not possible. Is anyone here facing this same problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Gallery 块中的每个图像都可以在
Advanced > 下分配自己的自定义 CSS 类。其他 CSS 类
。然后,自定义名称存储在块属性中,在执行自定义解析/渲染块时可以通过 PHP 访问这些属性。类名应用于 HTML,因为
我假设在 PHP 中您正在使用 parse_blocks() 或您自己的自定义函数来呈现内容。
Each Image within a Gallery block can have its own custom CSS class assigned under
Advanced > Additional CSS class(es)
. The custom names are then stored in the block attributes, which are accessible via PHP when doing custom parsing/rendering the block.The class name is applied to the HTML as
I assume in PHP you are using parse_blocks() or your own custom function to render the content.