That would be fantastic. I just found the line that handles this in the plugin.. Would you accept a PR that would add a filter to overwrite which attributes in which blocks can be overwritten? Something like:
(website\wp-content\plugins\threewp-broadcast\src\traits\attachments.php:360-383)
// This is for Gutenberg: <!-- wp:image {"id":1780} --> and <!-- wp:image {"id":1780,"align":"center"} -->
$content = preg_replace( '/(<!-- wp:image {"id":)' . $a->old->ID . '([},])/', '${1}' . $a->new->ID . '${2}', $content, -1, $count );
$total_count = $count;
// This is for custom Gutenberg blocks. Will replace old attachment IDs with the new attachment IDs
// Note that the format of the array needs to match an exact structure.
// Expects an array which has the block name in the key and the value containing an array of attributes
// i.e.
// array (
// 'wp:image' => array( 'id'),
// 'mc:custom_person' => array('headshot_image_id', 'favorite_image_id')
// );
$image_blocks = apply_filters( 'threewp_broadcast_media_blocks', array() );
if ( ! empty( $image_blocks ) ) {
foreach ($image_blocks as $block_slug => $block_atts ) {
foreach ( $block_atts as $block_att ) {
// For the current attribute in the current media_block, replace the old attachment ID with the new attachment ID
$content = preg_replace( '/(<!-- ' . $block_slug .' {"' . $block_att . '":)' . $a->old->ID . '([},])/', '${1}' . $a->new->ID . '${2}', $content, -1, $count );
$total_count += $count;
}
}
}
if ( $count > 0 )
$this->debug( 'Modified Gutenberg images: %s times', $total_count );
-
This reply was modified 5 years, 5 months ago by mclaurent.
-
This reply was modified 5 years, 5 months ago by mclaurent.