Skip to content

Instantly share code, notes, and snippets.

@daggerhart
Last active March 6, 2018 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save daggerhart/4fce93cfa23ff143f362 to your computer and use it in GitHub Desktop.
Save daggerhart/4fce93cfa23ff143f362 to your computer and use it in GitHub Desktop.
Allow HTML img tags in WordPress comments
<?php
add_filter( 'wp_kses_allowed_html', array( $this, 'my_kses_allowed_html_hook' ), 20, 2 );
function my_kses_allowed_html_hook( $tags, $context = null ){
if ( 'post' == $context && ! isset( $tags['img'] ) ) {
$tags['img'] = array(
'src' => 1,
'height' => 1,
'width' => 1,
'alt' => 1,
'title' => 1
);
}
return $tags;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment