How to allow data:image attribute in src tag during post insert?
Question
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 below 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?
0
allowedtags, wp-insert-post, wp-kses
3 years
2019-11-28T09:35:14-05:00
2019-11-28T09:35:14-05:00 0 Answers
74 views
0
Leave an answer