• Resolved whiteriverdesign

    (@whiteriverdesign)


    On the developer version the caption / title was not appearing despite ticking the box to enable it. This is because the image “link” requires the title tag to be on it, not the image itself. ie:

    <a href="“image" title="“image"><img scr=“image src” alt=“image title” alt=“image title”></a>

    By default the latest versions of wordpress don’t put the title tag on the image links anymore for gallery images. The below script (when added to the functions.php file) in wordpress force the image title tag to populate the link title tag with the same content, thus resolving the title tag not appearing issue.

    function add_title_attachment_link($link, $id = null) {
    $id = intval( $id );
    $_post = get_post( $id );
    $post_title = esc_attr( $_post->post_title );
    return str_replace(‘<a href’, ‘<a title=”‘. $post_title .'” href’, $link);
    }
    add_filter(‘wp_get_attachment_link’, ‘add_title_attachment_link’, 10, 2);

    Can’t take credit for the script above. Found it elsewhere online and it worked perfectly to resolve the issue. 😉

    https://wordpress.org/plugins/lightbox/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Fixed show the title issue’ is closed to new replies.