How to add an image select in your custom WordPress Gutenberg block?

How to add an image select in your custom WordPress Gutenberg block?

A thorough and detailed 10 step tutorial for beginners in Gutenberg in how to create your own custom WordPress Gutenberg block. With that out of the way, let’s dive right in! The select media function will functionally be exactly the same as WordPress’ featured image function.

Where do I find media ID in Gutenberg block?

We store the media ID and media URL in the block’s attributes. The code uses withSelect, a higher-order-component provided in wp.data package, to query more information about the selected media, by ID.

How to create an ACF block with innerblocks?

Rather than having to create your own fields for Title, Content, and Button in your custom block, you can simply insert and use the block editor to build the content inside the block. When registering your ACF block, include ‘jsx’ => true in the supports array.

How to add a link to an image in Gutenberg?

You can check out this impressive Gutenberg theme called Carrino – An Exciting Gutenberg Blog Theme. Hover over the block above which you want to add the image. A small plus icon will appear. Click on the plus icon. After you have clicked on the plus icon, you will be provided with several options. From that option choose the image block.

Is it good to use Gutenberg editor in WordPress?

Building a website using the default WordPress Gutenberg editor is extremely good for SEO. Pages or blogs made with Gutenberg get great Google page speed insights scores. So if you are looking to make a website then it might be better for you to use a ready made Gutenberg theme.

Do you need JavaScript to use Gutenberg blocks?

Keep in mind that because Gutenberg blocks are Javascript, modifying them requires you to write the code in Javascript. Just like WordPress’ PHP code has hooks and filters that allow theme or plugin developers to modify its code, there are also filters in WordPress’ Javascript code.

What’s the point of using Gutenberg in WordPress?

The whole point of Gutenberg is to implement a visual way to edit content where what we see is actually what we get. We want to achieve the same visual look both in editor and frontend. As mentioned above we can filter the block’s wrapping class name as this is a prop that is passed to all Gutenberg blocks.