Looking for all available options of Gutenberg Block

Option 1

Browse the block-library package in the Gutenberg’s GitHub repository, and find the block metadata in a JSON file named block.json of the specific block. For example, for the core/image block, you can find the metadata (e.g. all available/supported attributes) here:

https://github.com/WordPress/gutenberg/blob/master/packages/block-library/src/image/block.json

So basically, the URL format is:

https://github.com/WordPress/gutenberg/blob/master/packages/block-library/src/{name}/block.json

where {name} is the block name without the core/ part.

Option 2 (PHP)

For blocks registered using the PHP/WordPress function register_block_type, you can use this to get the block attributes:

$block = WP_Block_Type_Registry::get_instance()->get_registered( 'core/latest-posts' );
$attrs = $block ? $block->get_attributes() : [];
var_dump( $attrs, $block );

Option 3 (JavaScript)

For blocks registered using the JavaScript function wp.blocks.registerBlockType, you can use this to get the block attributes:

var block = wp.blocks.getBlockType('core/gallery');
var attrs = block ? block.attributes : {};
console.log( attrs, block );

Leave a Comment