Simple WordPress function to add custom classes to WordPress images automatically.

Copy custom classes function code and paste it in your functions.php file.

Custom Classes Function

This filter allows you to edit the classes that are automatically applied to images that are inserted into the TinyMCE editor via the Add Media button.

function my_image_class_filter($classes){
return $classes . ' another-image-class';
}
add_filter('get_image_tag_class', 'my_image_class_filter');

Note: this “another-image-class” is your html class, change it,
if you want to add more classes,
enter space between classes, like this: return $classes . ‘ myclass1 myclass2’;

Do you want to add class to links? Use Extend Link Plugin, All-In-One.