Skip to content

Instantly share code, notes, and snippets.

View stokesman's full-sized avatar

Mitchell Austin stokesman

View GitHub Profile
@stokesman
stokesman / image-block-filter.js
Created March 19, 2025 16:19
WP plugin: ensure the Image block will omit extraneous elements when not resizable. E.g. inside a Gallery block.
(({
compose: { createHigherOrderComponent },
element: { cloneElement, createElement: el },
hooks: { addFilter },
}) => {
const ImageInUnresizableContext = ({ blockEdit, blockEditProps: { context } }) => {
// If resize is not allowed then the Image block should omit the element used to
// limit the max width. Due to a bug it won’t, but it can be made to by adding a
// `type` property to the `__unstableParentLayout` prop.
if ( context.allowResize === false ) {