Take a closer look at get_image_tag() which can take a lot of parameters like $id
, $alt
, $title
, $align
, $size
.
If you look even closer you’ll find the get_image_tag_class
filter to change the image class names (like class, ID, align and size).
You can use the filter within your functions.php
like this:
Note: This will still return an empty tag like: class=""
function strip_image_class($class, $id, $align, $size) {
return '';
}
add_filter('get_image_tag_class', 'strip_image_class', 0, 4);
Update: To completely remove everything related to the class you’ll have to filter the $html
:
function strip_entire_image_class($html) {
return preg_replace('/ class="(.*)"https://wordpress.stackexchange.com/", '', $html);
}
add_filter('get_image_tag', 'strip_entire_image_class', 0, 4);