facetwp custom image size for ACF image field in layout builder

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/**
** for creating custom image sizes
** https://developer.wordpress.org/reference/functions/add_image_size/
**/
add_filter( 'facetwp_builder_item_value', function( $value, $item ) {
if ( 'my-image' == $item['settings']['name'] && !empty( $value ) ) { // change 'my-image' to the unique name of your field
$image = get_field('acf_image_field'); // change 'acf_image_field' to the name of your acf field
if ( $image ) $value = wp_get_attachment_image( $value, 'thumbnail' ); // 'thumbnail' can be changed to other image sizes you have available
}
return $value;
}, 10, 2 );
{{/gist}}