How to extend an existing (Gutenberg) block

Question

One of my WordPress sites has a custom field for media which contains the credit for the media item. (Something like “Photo by John Doe”.)

Before Gutenberg, I overwrote the default shortcode which displayed the image, to include the credit when displaying the image in the frontend. But, with Gutenberg blocks, this no longer works.

I could create a custom block from scratch which essentially would duplicate the image block, adding the credit, but this would mean a lot of unnecessary, duplicate, work.

Preferably, I somehow adjust the default’s block behaviour to add some HTML to the output of the block (which will include the credit) and to insert the credit into the block.

Is this possible? How? Where do I find a resource on how to extend existing blocks?

Alternatively, from where can I copy the code of the existing image block to create my own block, based on this existing block?

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/how-to-extend-an-existing-gutenberg-block/">

How to extend an existing (Gutenberg) block</a>
0
, MastaBaba 2 months 0 Answers 34 views 0

Leave an answer