Show a styled preview screenshot in the block inserter instead of a generic icon.
Add an example property to your block.json with sample data. ACF will render a live preview using these values in the block inserter:
{
"name": "acf/testimonial",
"title": "Testimonial",
"category": "theme",
"acf": {
"mode": "preview",
"renderTemplate": "blocks/testimonial/render.php"
},
"example": {
"attributes": {
"mode": "preview",
"data": {
"quote": "This product completely transformed our workflow.",
"author": "Jane Smith",
"role": "Head of Engineering",
"is_preview": true
}
}
}
}
To show a static screenshot image instead of a live render, check for the preview flag in your template:
<?php
if ( get_field( 'is_preview' ) ) : ?>
<img
src="<?php echo esc_url( get_template_directory_uri() . '/blocks/testimonial/preview.png' ); ?>"
alt="Testimonial block preview"
style="width:100%;height:auto;"
/>
<?php return;
endif;
?>
<!-- Normal block output below -->
This gives editors a polished visual in the inserter without needing to render the full block with placeholder data.