Last active
October 24, 2018 15:34
-
-
Save bolderelements/3efc46a2de8c20c16570528fcf393fec to your computer and use it in GitHub Desktop.
Add <img> tag to WordPress data elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Adds the <img> tag to allowed tags in fields sanitized using the wp_kses_data function. | |
* | |
* This particularly helps with adding images to Compare Table Features for individual products | |
*/ | |
add_filter( 'wp_kses_allowed_html', 'my_kses_allowed_html_hook', 23, 2 ); | |
function my_kses_allowed_html_hook( $allowed_tags, $context = null ){ | |
if ( 'post' == $context && ! isset( $allowed_tags['img'] ) ) { | |
$allowed_tags['img'] = array( | |
'alt' => true, | |
'align' => true, | |
'border' => true, | |
'height' => true, | |
'src' => true, | |
'width' => true, | |
'class' => true, | |
'id' => true, | |
'style' => true, | |
'title' => true, | |
); | |
} | |
return $allowed_tags; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment