Wordpress Image Remove Attributes


/ Published in: PHP

Remove the Attributes in - Tags in the Post/Page Content


Copy this code and paste it in your HTML
  1. add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
  2. add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
  3.  
  4. function remove_thumbnail_dimensions( $html ) {
  5. $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
  6. return $html;
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.