Is it possible to stop WordPress adding a width and height to an object when you pate it in to the source view?

When I paste in

<a href="#"><object data="grid-linked-in.svg" type="image/svg+xml"></object></a>

WP changes it to

<a href="#"><object width="300" height="150" type="image/svg+xml" data="grid-linked-in.svg"></object></a>

2 Answers
2

You can try this:

add_filter( 'media_send_to_editor', 'remove_width_height_attribute', 10 );

function remove_width_height_attribute( $html ) {
   $html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
   return $html;
}

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *