Support » Plugin: Simple Colorbox » No lightbox caption displaying

  • Resolved maustin89

    (@maustin89)


    First off I’d like to say that Simple Colorbox is a great plugin, the best that I know of to add lightbox-type overlay functionality. Thanks for creating it!

    I’m not sure whether or not my problem is related to a flaw with the plugin itself, but I have no idea what could be causing it and was hoping you could perhaps point me in the right direction. On one site only, the captions fail to appear at the bottom of the colorbox. If I edit an image, clicked on the “Advanced Settings” tab, and enter a title under “Advanced Link Settings”, then THAT appears as the caption, but nothing else works. On all other sites I have with Simple Colorbox installed, filling out just the basic Title field sets the caption (including on gallery images, for which one cannot even access the Advanced Settings AFAIK).

    I’ve tried reinstalling Simple Colorbox, and also switching to Twenty Twelve theme and disabling all plugins except for Simple Colorbox, but it has no effect. I’m so confused, do you have any ideas?

    Thanks!

    ETA – oh sorry, here’s the site: http://poptb.com/

    http://wordpress.org/plugins/simple-colorbox/

Viewing 15 replies - 1 through 15 (of 22 total)
  • Plugin Author Ryan Hellyer

    (@ryanhellyer)

    This should not happen with the Twenty Twelve theme and all plugins turned off. Are you sure you didn’t have any plugins running?

    Plugin Author Ryan Hellyer

    (@ryanhellyer)

    I’ve switched one of my blogs to Twenty Twelve to test this, but I don’t seem to be experiencing that problem.

    http://random.ryanhellyer.net/

    I understand this – I made my own test blog with the Twenty Twelve theme to confirm that it does work. However, I’m also extra super sure that all plugins were disabled and the Twenty Twelve theme active on this particular website, and it still wasn’t working, which is why I’m so confused.

    I changed the settings back just now, see the homepage: http://poptb.com The single image has the title set under the advanced tab, while the gallery thumbnails have it set as the regular title.

    Here’s my test site where everything’s working correctly: http://mjaustin.com/test/gallery/ I don’t actually see any captions on your random blog images, are the titles just not set?

    Could one of the plugins still be conflicting even though it’s disabled?

    Plugin Author Ryan Hellyer

    (@ryanhellyer)

    Plugins can’t conflict with anything if they aren’t activated.

    Since your test site is working, there must be a difference between your live site and the test site.

    This sort of problem is normally caused by the theme, but if it occurs with all plugins deactivated and using the Twenty Eleven theme, then I’m totally confused as to what the cause may be. I suspect you have simply forgotten something during the testing process. Perhaps an Mu plugin? Or maybe your Twenty Twelve theme has been modified?

    I’ve added captions and title tags to everything on this post so you can see it working on my blog:
    http://random.ryanhellyer.net/kristall-weiss/

    Ah, got it! PopTB is using 3.7 – I upgraded my test blog from 3.61 to 3.7 and the captions went away. See here: http://mjaustin.com/test/gallery/ (WP version is the only thing I changed.) Can you confirm this with yours?

    Plugin Author Ryan Hellyer

    (@ryanhellyer)

    I’m running 3.8 trunk and don’t see that problem.

    I’m not sure if you’re saying that I should be running 3.8 trunk too, that 3.7 isn’t the problem, or that you just can’t be bothered to test 3.7 and confirm one way or the other, but these are my findings from experimenting on multiple installations of different versions of WordPress, from 3.3 to 3.6-ish.

    In all cases a single image inserted into a post did not use the title field for the caption at all, it *only* responded to the Advanced Link Settings title field. In all cases, the images DID use the regular title field as the caption when they were part of a gallery. In all cases, when the blog was upgraded to 3.7 using the auto-update feature, the gallery images no longer used the title field as a caption and the single images continued to use the Advanced Link Settings title as a caption.

    This is demonstrated on my test blog, which prior to upgrading the WP version was used as a demonstration of correct Simple Colorbox caption functionality. This proves that there are no other potential conflicts on this particular blog, which was created only a few days ago and has no customizations of any kind. I’ve demonstrated both working and nonworking caption settings on single images here: http://mjaustin.com/test/gallery/

    Thoughts?

    Plugin Author Ryan Hellyer

    (@ryanhellyer)

    I don’t see any problem. I can’t replicate the bug and I can’t see any way that upgrading WordPress versions could affect this sort of thing.

    I also can’t see any problems on your test site either, it seems to be working just fine. Below is a screenshot showing the caption appearing as expected:
    http://stuff.ryanhellyer.net/working.png

    Plugin Author Ryan Hellyer

    (@ryanhellyer)

    I think I follow what you are meaning now. When you say it doesn’t work on upgrading, I’m guessing you are referring to WordPress having changed the way it handles title attributes via the media inserter. Presumably nothing breaks, it’s just that when using the media inserting tool, it probably behaves different between WordPress versions which is quite possible. That sort of issue is somewhat outside the scope of this plugin though since it is an implementation of the Colorbox jQuery plugin, which uses title tags on link tags and has nothing to do with how WordPress internally handles it’s default HTML output from the media inserting tool.

    Heh, I suppose you didn’t read my post very carefully because your screenshot shows the one image I specifically labeled as working because it uses the alternate title field under the advanced settings tab, and ignored the fact that all the other images on that page have no caption. hehehe, that made me giggle. 😛

    But yes, turns out you’re correct. Apparently the title tag was purposely stripped from embedded images back in 3.5, resulting in much hoopla due to missing tool-tips and broken lightbox captions and the like. I checked my page source and the title field now seems to add an alt attribute, even if one is not set.

    For anyone having the same problem, at the moment the closest solution I’ve found is a short snippet that adds the title back to the embedded single images, but not the gallery images. See here:

    WordPress: Add Image Title in Image Links in WP 3.5

    A solution for restoring the title attribute to gallery images:

    //Add title attribute back to gallery images
    function my_image_titles($atts,$img) {
    	$atts['title'] = trim(strip_tags( $img->post_title ));
    	return $atts;
    }
    add_filter('wp_get_attachment_image_attributes','my_image_titles',10,2);

    From here: http://wordpress.org/support/topic/restoring-titles-to-inserted-images-in-wordpress-35?replies=12

    And, a hackish solution based on the above for restoring the title attribute to the links that wrap the gallery images, which are apparently what Simple Colorbox uses to derive captions:

    //Add title attribute back to gallery image links
    function my_get_attachment_link_filter( $content,$id ) {
            $title = get_the_title($id);
            $new_content = str_replace("<a ", "<a title=\"$title\" ", $content);
            return $new_content;
    }
    add_filter('wp_get_attachment_link', 'my_get_attachment_link_filter', 10, 4);

    Based on this and this and thisish.

    Ahhh, captions are glorious.

    Plugin Author Ryan Hellyer

    (@ryanhellyer)

    Glad to hear you’ve found a solution to your problem 🙂

    I want to echo that I had the same problem. Upgrading to WordPress 3.7 broke captions. I only had to add the following. Changed the above to use esc_attr() which is the appropriate function rather than stirp_tags().

    function my_get_attachment_link_filter( $content,$id ) {
            $title = get_the_title($id);
            $new_content = str_replace('<a ', '<a title="' . esc_attr($title) . '" ', $content);
            return $new_content;
    }
    add_filter('wp_get_attachment_link', 'my_get_attachment_link_filter', 10, 4);
    Plugin Author Ryan Hellyer

    (@ryanhellyer)

    That’s an odd bit of code. I’m surprised the patch got committed with strip_tags() used for an attribute like that.

    Cool, thanks! I’ll take your word for it that it’s a superior solution.

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘No lightbox caption displaying’ is closed to new replies.