If you want to add a class to the attachment images in WordPress? Use following code in your theme’s functions.php file OR in site specific plugin.
1 2 3 4 5 | function image_tag_class($class) { $class .= ' my-custom-class'; return $class; } add_filter('get_image_tag_class', 'image_tag_class' ); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.