Title: Adding custom class to image
Last modified: August 31, 2016

---

# Adding custom class to image

 *  Resolved [DerekJR123](https://wordpress.org/support/users/derekjr123/)
 * (@derekjr123)
 * [10 years ago](https://wordpress.org/support/topic/adding-custom-class-to-image/)
 * Hello,
 * I am wondering if there is any way to add a custom class to the thumbnail image?(
   wpmtst_the_thumbnail()).
 * I tried putting it inside the brackets just as a shot in the dark but it didn’t
   work.
 * Also, just as a separate question, is there a way to break up the full name and
   the company name for purposes of template styling? Right now I’m just showing
   them as <h2>? wpmtst_the_client ?</h2>. I’d like to be able to use a smaller 
   font size for the company name. Just curious if its possible.
 * Thanks,
 * Derek
 * [https://wordpress.org/plugins/strong-testimonials/](https://wordpress.org/plugins/strong-testimonials/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Thread Starter [DerekJR123](https://wordpress.org/support/users/derekjr123/)
 * (@derekjr123)
 * [10 years ago](https://wordpress.org/support/topic/adding-custom-class-to-image/#post-7372260)
 * *note*
 * Please disregard my second question. I figured out a way to solve the problem.
 * Thanks,
    Derek
 *  anonymized-13171256
 * (@anonymized-13171256)
 * [10 years ago](https://wordpress.org/support/topic/adding-custom-class-to-image/#post-7372302)
 * Hi Derek,
 * You can always reach it in CSS with:
 *     ```
       .testimonial-image img {}
       ```
   
 * Or use the image attributes filter:
 *     ```
       function testimonial_image_attr( $attr, $attachment, $size ) {
       	if ( 'wpm-testimonial' == get_post_type( get_post( $attachment->post_parent ) ) ) {
       		// a space before the name
       		$attr['class'] .= ' my-custom-class';
       	}
   
       	return $attr;
       }
       add_filter( 'wp_get_attachment_image_attributes', 'testimonial_image_attr', 10, 3 );
       ```
   
 *  Thread Starter [DerekJR123](https://wordpress.org/support/users/derekjr123/)
 * (@derekjr123)
 * [10 years ago](https://wordpress.org/support/topic/adding-custom-class-to-image/#post-7372350)
 * Ah excellent. Thank you very much.
 * Another question… sorry for the barrage.
 * Every time I update the plugin, it ends up deleting my custom templates. Where
   should I be putting them? I tried putting them in my theme as a child element
   but it doesn’t seem to work. Any thoughts?
 * Thanks,
 * Derek
 *  anonymized-13171256
 * (@anonymized-13171256)
 * [10 years ago](https://wordpress.org/support/topic/adding-custom-class-to-image/#post-7372354)
 * That tutorial will be the first thing I do after the big project I’m currently
   working on 🙂
 *     ```
       {theme}/strong-testimonials/my-custom-template/content.php
       {theme}/strong-testimonials/my-custom-template/content.css
       ```
   
 * Same pattern for the widget and the form.
 * There are Sass files in {plugin}/templates-scss if you’re so inclined.
 *  anonymized-13171256
 * (@anonymized-13171256)
 * [10 years ago](https://wordpress.org/support/topic/adding-custom-class-to-image/#post-7372355)
 * Here is an add-on plugin that may make it simpler.
    [https://github.com/cdillon/strong-testimonials-custom-template](https://github.com/cdillon/strong-testimonials-custom-template)
 *  Thread Starter [DerekJR123](https://wordpress.org/support/users/derekjr123/)
 * (@derekjr123)
 * [10 years ago](https://wordpress.org/support/topic/adding-custom-class-to-image/#post-7372391)
 * Thank you again for your replies. They have helped me a lot. I appreciate it.
 * 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Adding custom class to image’ is closed to new replies.

 * ![](https://ps.w.org/strong-testimonials/assets/icon-256x256.png?rev=3134855)
 * [Strong Testimonials](https://wordpress.org/plugins/strong-testimonials/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/strong-testimonials/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/strong-testimonials/)
 * [Active Topics](https://wordpress.org/support/plugin/strong-testimonials/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/strong-testimonials/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/strong-testimonials/reviews/)

## Tags

 * [custom class](https://wordpress.org/support/topic-tag/custom-class/)

 * 6 replies
 * 2 participants
 * Last reply from: [DerekJR123](https://wordpress.org/support/users/derekjr123/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/adding-custom-class-to-image/#post-7372391)
 * Status: resolved