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

Register block preview image with acf_register_block_type #48

Open
andevit opened this issue Sep 15, 2020 · 4 comments
Open

Register block preview image with acf_register_block_type #48

andevit opened this issue Sep 15, 2020 · 4 comments

Comments

@andevit
Copy link

andevit commented Sep 15, 2020

Hi guys!
There is a solution for add a preview image for the core Gutenberg blocks when you hover over their icons in the top left add block popup?

It would be great to be able to set a static image for custom blocks registered with acf_register_block_type.

For example we could add a "PreviewImage" like this:

{{--
  Title: Name Block
  Description: Description Block
  Category: formatting
  Icon: admin-comments
  Keywords: quote
  Mode: edit
  Align: left
  PostTypes: page post
  SupportsAlign: left right
  SupportsMode: false
  SupportsMultiple: false
  EnqueueStyle: styles/style.css
  EnqueueScript: scripts/script.js
  EnqueueAssets: path/to/asset
  Preview: true
  PreviewImage: path/to/my/block/preview.jpg
--}}

Can you help me?

@robmeijerink
Copy link
Contributor

Hi!

Looking at ACF's documentation, are you referring to the section with Header: Adding block previews ?

@atoupet-toki
Copy link

Hi @andevit did you find something ?? It's exactly what I need 😬

@igor-sumonja
Copy link

you can add dummy preview data like like this in meantime
Simple hook into filter

`add_filter('sage/blocks/button/register-data', function ($data) {

$data['example'] = [
    'attributes' => [
        'mode' => 'preview',
        'data' => [
            'link' => [
                'title' => 'Change me',
                'url' => '#',
                'target' => '_self'
            ],
            'type' => 'primary',
            'size' => 'regular',
            'icon' => '',
        ]
    ]
];

return $data;

});
`

@mantrone
Copy link

Any progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants