Quick gallery not displaying image attachment titles in WordPress 3.7

WordPress 3.7 applied a modification to the markup generated in the WordPress gallery (or as we call it Quick Gallery) in which the title attribute is not added to the anchor of the image. Some of our themes use this attribute to display the title in the image lightbox preview, however after this modification was applied in WordPress, the title of the image is not added to the markup by WordPress and therefore it is not displayed in the lightbox preview as well.

We are following the WordPress development and hope that the title attribute will be added back to the markup, if it turns to be a permanent modification in WordPress, we will release updates of our themes to apply a filter to the WordPress attachment markup and add the title to the anchor tag. Meanwhile if you would like to add a description/title to your images, you can also use the Alt Text field of the image that is also displayed to the lightbox preview image or you can add the following code in the end of the theme’s functions.php file:

function pexeto_add_title_to_attachment( $markup, $id ){
$att = get_post( $id );
return str_replace('<a ', '<a title="'.$att->post_title.'" ', $markup);

}
add_filter('wp_get_attachment_link', 'pexeto_add_title_to_attachment', 10, 5);

Was this useful? 2