Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use filter on parsed result of blocks in place of regular expression #12134

Closed
antpb opened this issue Nov 20, 2018 · 2 comments
Closed

Use filter on parsed result of blocks in place of regular expression #12134

antpb opened this issue Nov 20, 2018 · 2 comments
Labels
[Feature] Blocks Overall functionality of blocks
Milestone

Comments

@antpb
Copy link
Contributor

antpb commented Nov 20, 2018

In #11973 there was talk of needing a way to parse the results of a block instead of using regular expression.

@aduth mentioned: #11973 (comment)

Since this doesn't exist as an option today anyways (requires filter on this value), we probably can't do anything of this sort right now.

@dmsnell mentioned #11973 (comment)

if we hook into the block-level filter (the design of which I favor in #10108) then we can track the parse through the blocks and then prime the cache on the do_blocks filter which occurs after parsing and rendering is complete.

that is, we could imagine something like this…

function _gutenberg_cache_images_meta( $html, $block ) {
	if ( $block['blockName'] === 'core/image' ) {
		$this->add_image( $block['attrs']['id'] );
	}

	return $html;
}
add_filter( 'rendered_block', '_gutenberg_cache_images_meta', 3 );

function _gutenberg_prime_cache() {
	if ( empty( $this->images ) ) {
		return;
	}

	// whatever command does all images in one go
	_prime_post_caches( $this->images, false, true, true, true, false, false );
}
add_filter( 'do_blocks', '_gutenberg_prime_cache' );

and this because we know that the final do_blocks filter runs after block-level processing.

As work is completing in #11973, I am creating this issue to kick off discussion around adding a filter to parse block content.

@antpb antpb added this to the Future: 5.1 milestone Nov 20, 2018
@antpb antpb added the [Feature] Blocks Overall functionality of blocks label Nov 20, 2018
@paaljoachim
Copy link
Contributor

Hey Anthony

Is this issue still relevant?

@jordesign
Copy link
Contributor

As there's been no reply or movement on this in 2 and a bit years - I'm going to close it. Feel free to re-open if needed,

@jordesign jordesign closed this as not planned Won't fix, can't repro, duplicate, stale Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks
Projects
None yet
Development

No branches or pull requests

3 participants