• Hi all,

    I’m trying to load thickbox via wp_enqueue_style and wp_enqueue_script, and it works, but the “Close” link is missing. There is a dark gray bar where the link would have been, so you can click on it to close it, but he “Close” word is missing.

    Here’s the code I used to generate it:

    wp_enqueue_script('thickbox');
        wp_enqueue_style('thickbox');

    Here’s the code generated (at the bottom of my page):

    <script type='text/javascript'>
    /* <![CDATA[ */
    var thickboxL10n = {
    	next: "Next >",
    	prev: "< Prev",
    	image: "Image",
    	of: "of",
    	close: "Close"
    };
    try{convertEntities(thickboxL10n);}catch(e){};
    /* ]]> */
    </script>
    <script type='text/javascript' src='https://dmt.rrc.mb.ca/aramirez/wordpress/wp-includes/js/thickbox/thickbox.js?ver=3.1-20091124'></script>
    <script type='text/javascript' src='https://dmt.rrc.mb.ca/aramirez/wordpress/wp-includes/js/jquery/jquery.form.js?ver=2.02m'></script>

    Am I missing something?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter coopersita

    (@coopersita)

    I checked the generated code, and it’s trying to load the “Close” image from the wrong location:

    <img src="../wp-includes/js/thickbox/tb-close.png">

    Is there a way to fix this without touching the thickbox code? Perhaps pass the location as a parameter?

    Thanks

    Update the vars tb_pathToImage and tb_closeImage in your first piece of JS…

    <script type='text/javascript'>
    /* <![CDATA[ */
    var tb_pathToImage = "<?php echo get_option('siteurl').'/'. WPINC.'/js/thickbox/loadingAnimation.gif'; ?>";
    var tb_closeImage = "<?php echo get_option('siteurl').'/'. WPINC.'/js/thickbox/tb-close.png'; ?>";
    var thickboxL10n = {
    	next: "Next >",
    	prev: "< Prev",
    	image: "Image",
    	of: "of",
    	close: "Close"
    };
    try{convertEntities(thickboxL10n);}catch(e){};
    /* ]]> */
    </script>

    Hope that helps..

    A slightly slimmer alternative. Try adding this to your theme’s functions.php file:

    // Correct image path issue in thickbox
    function load_tb_fix() {
    	echo "\n" . '<script type="text/javascript">tb_pathToImage = "' . get_option('siteurl') . '/wp-includes/js/thickbox/loadingAnimation.gif";tb_closeImage = "' . get_option('siteurl') . '/wp-includes/js/thickbox/tb-close.png";</script>'. "\n";
    }
    add_action('wp_footer', 'load_tb_fix');

    I also add this one to keep page bloat down:

    // Add thickbox to public-facing image attachment pages only
    function thickbox_init() {
    	if ( function_exists('add_thickbox') && is_attachment() && substr(get_post_mime_type(), 0,5) == 'image') {
    		add_thickbox();
    	}
    }
    add_action('template_redirect', 'thickbox_init');

    thanks esmi, exactly what I needed!
    any idea why this happens?

    Ok, I’ve modified P2 and added it to my theme, here https://blog.twittrblog.com the only issue is the thick box, I’ve added what esmi posted but the media buttons pop up in a new window. Of course I am trying this in chrome, but didn’t know if there was any other issue that I need to fix can anyone help?

    Esmi! You saved me! Or your little snippet did. That was exactly what I needed. Blessings be upon you, for sure. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Thickbox “Close” not showing’ is closed to new replies.