• Hi? how can i add valus for attributes?
    example:
    i have string

    
    <img src=\"C:/Users/Богдан/Desktop/emoji-picker-master/lib/img//blank.gif\" class=\"img\" style=\"display:inline-block;width:25px;height:25px;background:url('C:/Users/Богдан/Desktop/emoji-picker-master/lib/img//emoji_spritesheet_0.png') -475px -150px no-repeat;background-size:675px 175px;\" alt=\":kiss:\">
    

    after cleaning by wp_kses_post() i get

    
    <img src="/Users/Богдан/Desktop/emoji-picker-master/lib/img//blank.gif" class="img" style="width:25px;height:25px;background-size:675px 175px" alt=":kiss:"/>
    

    i try fix this by code

    
    function allow_onclick_content($allowedposttags) {
    
      $allowedposttags["img"]['display'] = true;
        $allowedposttags["img"]['background'] = true;
    
        return $allowedposttags;
    }
    add_filter(  'wp_kses_allowed_html', 'allow_onclick_content' );
    

    but it`s not help. How to allow display and background for style-attribute in img-tag?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    All “wp_kses_allowed_html” does is determine what attributes are allowed in various tags. It doesn’t manage what values are assigned to attributes. What your code is doing is allowing attributes “display” and “background”, not style values. As I’m sure you are aware, there are no such attributes for img tags 😉

    I think what’s happening with your img tags is some other code is altering the style attribute value, but it’s not the WP kses scheme. I tried placing your first img tag in post content on my site and the styles came through unchanged although the quotes got all messed up because they were escaped. Your filter code was not in place, only the default WP filtering was used. Thus your styles were altered by some code that’s not part of default WP.

Viewing 1 replies (of 1 total)
  • The topic ‘Allowed post tags & attributes’ is closed to new replies.