Reputation: 221
WordPress adds a lot of extra classes and attributes to different elements when creating a post in the WYSIWYG editor. Is there any way to prevent those classes from being added using the functions.php file?
In this case, alignnone size-full wp-image-540
are just extra classes that I don't need. Similarly, I don't want to set fixed width
and height
attributes. I am using my-class
to set a max-width
to 50% but the image does not stay in its original proportions on resizing the window because WordPress sets the width and height values by itself.
Is there any code that I can write in functions.php file to prevent WordPress from automatically applying any kind of attributes and classes on elements?
Upvotes: 2
Views: 650
Reputation: 65
You can see the full functions here. So just add this to your code
this should filter the get_image_tag_class
and the __return_empty_string
classes:
add_filter( 'get_image_tag_class', '__return_empty_string' );
Upvotes: 1
Reputation: 546
Looks like this will do it:
add_filter( 'get_image_tag_class', '__return_empty_string' );
Try adding that to your functions.php. The functions can be found here
Upvotes: 2