Support » Fixing WordPress » How To implement Thickbox to all images which contain a refered link?
8 years, 5 months ago
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.
8 years, 3 months ago
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">
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 bueltge.de in functions.php:
$content = preg_replace('/<a(.*?)href="(.*?).(jpg|jpeg|png|gif|bmp|ico)"(.*?)><img/U', '<a$1href="$2.$3" $4 class="thickbox"><img', $content);
add_filter('the_content', 'fb_add_thickbox', 2);
Thanks to bueltge!!!