Interfacelab / ilab-media-tools

https://mediacloud.press/
GNU General Public License v3.0
114 stars 37 forks source link

Block filtering broke WP Cover block markup #232

Open qzya opened 5 months ago

qzya commented 5 months ago

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>