Title: Image title attribute
Last modified: August 22, 2016

---

# Image title attribute

 *  [TJ Kelly](https://wordpress.org/support/users/tjkelly/)
 * (@tjkelly)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/image-title-attribute/)
 * I love this plugin, thanks for sharing it with the world. Is there any way to
   get the image title attribute to show up? I’m hoping to use the Fancybox title
   functionality. Thank you!
 * [https://wordpress.org/plugins/cleaner-gallery/](https://wordpress.org/plugins/cleaner-gallery/)

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

 *  [kerec](https://wordpress.org/support/users/kerec/)
 * (@kerec)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/image-title-attribute/#post-5902918)
 * Perhaps [this ](https://groups.google.com/forum/#!topic/fancybox/PaFNiK8jk8w)
   could help?
 *  Thread Starter [TJ Kelly](https://wordpress.org/support/users/tjkelly/)
 * (@tjkelly)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/image-title-attribute/#post-5902922)
 * Thanks [@kerec](https://wordpress.org/support/users/kerec/). I already have a
   similar javascript solution in place. I’m hoping for a way to do it without the
   JS setting. The title and alt should be different in most cases. Right now I 
   have to use my alt like a title. Hoping to avoid that.
 *  [kerec](https://wordpress.org/support/users/kerec/)
 * (@kerec)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/image-title-attribute/#post-5902942)
 * With JS, perhaps you could create your titles from custom attributes, a bit like
   [here](http://stackoverflow.com/questions/12352927/fancybox-add-caption-and-other-things),
   only setting the attr ?
 *  [landwire](https://wordpress.org/support/users/landwire/)
 * (@landwire)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/image-title-attribute/#post-5903056)
 * Not sure if it help, but I would use the “cleaner_gallery_image” filter to add
   the image title attribute:
 *     ```
       /* Filter the gallery images with user options. */
       add_filter( 'cleaner_gallery_image', 'lw_add_title_tag_image', 10, 2 );
   
       /**
        * Filters the gallery image if it has a link and adds the appropriate attributes for the lightbox
        * scripts.
        *
        * @since  0.9.0
        * @access public
        * @param  string  $image
        * @param  int     $id - the attachment ID
        * @param  array   $attr
        * @param  int     $instance
        * @return string
        */
       function lw_add_title_tag_image( $image, $id ) {
   
       	$attachment_title = get_the_title($id);
       	$image = str_replace( '<img ', '<img title="' . $attachment_title . '" ' , $image );
   
       	return $image;
       }
       ```
   
 *  Thread Starter [TJ Kelly](https://wordpress.org/support/users/tjkelly/)
 * (@tjkelly)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/image-title-attribute/#post-5903057)
 * Thanks [@landwire](https://wordpress.org/support/users/landwire/). That looks
   like it should work. The str_replace isn’t my favorite method, but it would accomplish
   the goal. Thanks for sharing.

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

The topic ‘Image title attribute’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/cleaner-gallery_cfd5de.svg)
 * [Cleaner Gallery](https://wordpress.org/plugins/cleaner-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cleaner-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cleaner-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/cleaner-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cleaner-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cleaner-gallery/reviews/)

## Tags

 * [alt](https://wordpress.org/support/topic-tag/alt/)
 * [title](https://wordpress.org/support/topic-tag/title/)

 * 5 replies
 * 3 participants
 * Last reply from: [TJ Kelly](https://wordpress.org/support/users/tjkelly/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/image-title-attribute/#post-5903057)
 * Status: not resolved