Support

Account

Home Forums ACF PRO Post_object field with thumbnails Reply To: Post_object field with thumbnails

  • Hi guys,
    trying to create thumbnails in my input post_object fields with post_object result filter

    
    function post_object_with_avatar( $title, $post, $field, $post_id ) {
    
      $post_thumbnail_url = get_the_post_thumbnail_url($post->ID);
    
      $avatar = '<div class="post_ava_prefilter_wrapper" title="'.$title.'">';
        $avatar .= '<div class="ava_prefilter_wrapper"><img class="ava_square" src="'.$post_thumbnail_url.'" /></div>';
      $avatar .= '</div>';
    
      return $avatar;
    }
    
    add_filter('acf/fields/post_object/result/name=users_with_avatars_list', 'post_object_with_avatar', 10, 4);
    

    everything works fine except one thing, I see this html code ($avatar variable returns) in the Title tag in every li.select2-selection__choice element, I understand why, because post_object_with_avatar function should return text instead of html code.

    To be clear, every li has tag title=”<div class=”post_ava_prefilter_wrapper” title=”…”…>Could you suggest any solution please how to avoid inserting html in title tags ?

    Everything works great I see thumbnails, except title tags.

    Thank you