Howdy howdy,
My client is looking to have a color swatch (an image) shown in the Post Object select – so they can see the color they are selecting. I have it mostly working with something like…
// Add image to Post Object
function my_post_object_result( $result, $object, $field, $post ) {
$image = wp_get_attachment_image( get_field( 'field_54505e6d8895d', $object-ID ) );
return $image . ' ' . $result;
}
add_filter('acf/fields/post_object/result/key=field_5459453011f26', 'my_post_object_result', 10, 4);
It works fine when it first comes up and as you scroll down through the options. However, if you search for a color then only a few of the options have the image…
http://screencast.com/t/tTdyYgMKlpe
Any ideas why or how to fix?
Thanks!
Philip
Also, the color shows when you select an option – but not after saving…
http://screencast.com/t/tJbpdXD7UkZG
Need to figure out as well how to get them to show there.
Thanks 🙂
Same problem here: after saving the image disappear from the selected value.
I think that any html tags is stripped off before loaded into the .select2-choice container.
Hope it could be solve soon.