preg_replace not removed “class”

The hook post_thumbnail_html is just working for featured images aka post thumbnails, hence the name. I’m guessing that’s what you’re missing and where the “problem” originates.

But luckily there is another hook for manipulating image tags get_image_tag, there is actually one for just altering the class get_image_tag_class too. Take a look into those.

Another hook used in these scenarios is wp_get_attachment_image_attributes, but I only mention this one for completeness reasons.