-
Notifications
You must be signed in to change notification settings - Fork 2
/
lazyblocks.php
37 lines (33 loc) · 1.26 KB
/
lazyblocks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* @file Lazy blocks snippets
* @author Thomas Fellinger <[email protected]>
* @license GPL-2.0-or-later
* @link https://github.com/netzgestaltung/wordpress-snippets/blob/master/lazyblocks.php
*/
/**
* remove lazy blocks wrapper container markup in frontend
* @see https://lazyblocks.com/documentation/blocks-code/php-callback/
*/
add_filter('lzb/block_render/allow_wrapper', '__return_false');
/**
* Additional lazy blocks Handlebars helper
* @see https://lazyblocks.com/documentation/php-actions/lzb-handlebars-object/
*/
function myPlugin_lazyblocks_handlebars_helper($handlebars){
/**
* wp_get_attachment_image Handlebars helper
* @link https://github.com/nk-o/lazy-blocks/issues/68
* @see https://developer.wordpress.org/reference/functions/wp_get_attachment_image/
* @see https://lazyblocks.com/documentation/blocks-controls/image/
*
* @example
* {{{ wp_get_attachment_image control_name 'thumbnail' }}}
*/
$handlebars->registerHelper('wp_get_attachment_image', function($image, $size=null){
if ( isset($image['id']) ) {
return wp_get_attachment_image($image['id'], $size);
}
});
}
// lazy block Handlebars helper
add_action('lzb_handlebars_object', 'myPlugin_lazyblocks_handlebars_helper');