Skip to content

Instantly share code, notes, and snippets.

@djrmom
Last active December 28, 2020 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djrmom/4e25495948d52ad9fc93c975c04071f3 to your computer and use it in GitHub Desktop.
Save djrmom/4e25495948d52ad9fc93c975c04071f3 to your computer and use it in GitHub Desktop.
facetwp custom image size for ACF image field in layout builder
<?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( $image, 'thumbnail' ); // 'thumbnail' can be changed to other image sizes you have available
}
return $value;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment