Support » Fixing WordPress » How To implement Thickbox to all images which contain a refered link?

  • I want, that all preview pictures in my blog, which have a refered link to a larger one, to be open by Thickbox without adding the class (class=”thickbox”) to each image in the code. For this purpose I’ve found a Plugin which is called Thickboxalize, but it doesn’t work.

Viewing 1 replies (of 1 total)
  • Thickbox has to be loaded by a plugin or manually in the header between this two tags:

    <?php wp_head(); ?>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/thickbox/thickbox.css" type="text/css" media="screen, projection">
    <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/thickbox/jquery-latest.pack.js"></script>
    <script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/thickbox/thickbox.js"></script>

    As a matter of course the jQuery-Framework and Thickbox have to be copied in your theme or you use the already existing one in wp-includes/js/.

    Then you add the following code (found on in functions.php:

    function fb_add_thickbox($content){
    	$content = preg_replace('/<a(.*?)href="(.*?).(jpg|jpeg|png|gif|bmp|ico)"(.*?)><img/U', '<a$1href="$2.$3" $4 class="thickbox"><img', $content);
    	return $content;
    add_filter('the_content', 'fb_add_thickbox', 2);

    Thanks to bueltge!!!

Viewing 1 replies (of 1 total)
  • The topic ‘How To implement Thickbox to all images which contain a refered link?’ is closed to new replies.