ilab-media-tools icon indicating copy to clipboard operation
ilab-media-tools copied to clipboard

Block filtering broke WP Cover block markup

Open qzya opened this issue 1 year ago • 0 comments

Block processing in https://github.com/Interfacelab/ilab-media-tools/blob/74c3a0031717c77b4baef469a9789fbd3c01439a/classes/Tools/Storage/StorageContentHooks.php#L187 totally breaks markup of WordPress Cover Block: str_replace() adds the mcloud-attachment-{$id} class for class lists that contain such classes like wp-block-cover-is-layout-constrained or wp-block-cover__image-background and not only for class lists that contain the wp-cover-block class.

For example, this markup:

<div class="wp-block-cover">
    <span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span>
    <img
        class="wp-block-cover__image-background wp-image-220145"
     >
    <div class="wp-block-cover__inner-container is-layout-constrained wp-block-cover-is-layout-constrained">
        <p class="has-text-align-center has-large-font-size">Cover title</p>
    </div>
</div>

turns to

<div class="wp-block-cover mcloud-attachment-220145">
    <span aria-hidden="true" class="wp-block-cover mcloud-attachment-220145__background has-background-dim"></span>
    <img 
        class="wp-block-cover mcloud-attachment-220145__image-background wp-image-220145"
    >
    <div class="wp-block-cover mcloud-attachment-220145__inner-container is-layout-constrained wp-block-cover mcloud-attachment-220145-is-layout-constrained">
        <p class="has-text-align-center has-large-font-size">Cover title</p>
    </div>
</div>

qzya avatar Jun 24 '24 20:06 qzya