Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
dmitry01
ParticipantThanks, Ernest! The example you provide works great if in the ACF settings the return format is set to ‘Image ID’. In my case it was ‘Image Array’ so I modified the code a bit:
add_filter( 'asp_results', 'asp_get_main_prod_img', 10, 1 ); function asp_get_main_prod_img($results) { $acf_image_field = 'design_image'; $size = 'medium'; foreach ( $results as $k => &$r ) { if ( empty($r->image) && function_exists('get_field') ) { $image_array = get_field( $acf_image_field, $r->id ); if ( count( $image_array ) > 0 && array_key_exists( 'sizes', $image_array ) ) { $img = $image_array['sizes'][$size]; if ( isset( $img ) && !is_wp_error( $img ) ) $r->image = $img; } } } return $results; }Thank you for the help!
dmitry01
Participant1. Thanks!
2. Thanks, I saw it and it works, but as far as I understand this is not about indexing, products hidden from the catalog will still be included into index. This is not important actually as the current solution works fine.
3. Those images are uploaded with ACF in my case and have the [‘sizes’] array with all image sizes. Maybe there is a way to access this array and assign (hard-code) the medium size to images of a specific custom post type? -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)