I'm inserting a post using wp_post_insert()
. And my post's content looks like this:
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAN4AAAB6CA { ... }
but on the insert process, Wordpress removes
the data attribute. So above code becomes this:
<img src="image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAN4AAAB6CA { ... }
I've tried something like this but no luck:
function my_filter_allowed_html($allowed, $context){
if (is_array($context)) {
return $allowed;
}
if ($context === 'post') {
$allowed['img']['data'] = true;
$allowed['src']['data'] = true;
}
return $allowed;
}
add_filter('wp_kses_allowed_html', 'my_filter_allowed_html', 10, 2);
How can I avoid this?