ACF 5.10.0 added wp_kses
which is stopping images from loading inside select fields. I used to be able to use the “Stylized UI” Select field with values like this:
announcement : <img src="https://web.com/announcement.img">
arrow : <img src="https://web.com/arrow.img">
But it echos out <
instead of <
and >
instead of >
around the image tag, which keeps it from rendering.
I’ve tried updating the wp_kses_allowed_html
filter but nothing seems to make a difference.
Hey, thanks for the report!
We’re intended to release a patch next week that will allow safe HTML like this inside a select2 field.
Hey there!
I’m seeing the same problem – is there any solution for that?
I do have a select field with the stylized UI set to true and the following choices
jacquarda : <span class="ff--jac">Jacquarda</span>
clay : <span class="ff--cla">Clay</span>
The wp_kses_allowed_html
filter shows that the span
tag is allowed for the acf context.
Thanks a lot!
Due to the way select2 works, we’ve had to disable html in select2 results by default, restoring the default select2 behaviour.
Instead, you need to manually override the escaping function using a JS filter for a specific field type, key or name.
You can find more information on this here: https://www.advancedcustomfields.com/resources/javascript-api/#filters-select2_escape_markup