I'm using the Lightbox 2.9.2 (Rupert Morris, based on ) on my Wordpress blog (designink.nl) and use the auto-lightbox setting (lets the plugin add html to image links). However, i'd like to prevent a specific image on a post to be called by lightbox. Is there a code to break/prevent this on individual instance and not change my automatic-setting?
A:
I haven't had a chance to try this out, but you could try printing this bit of jQuery in the header of your website:
var no_light_box = jQuery("img[src$='THE_IMAGE_PATH']"); //Specify your image
jQuery(no_light_box).attr({ rel: "" }); //Reset the rel value
Essentially you're going to find the image path of the image you do not want to have light box and then reset it's rel attribute from lightbox[26] (this seems standard in that plugin to nothing, so it will not initiate a lightbox when clicked.
It would probably be easier and more manageable if you implemented your own lightbox code.
hsatterwhite
2010-05-12 13:34:25
Sorry, i'm green. Do you mean in (a) httpdocs>index.htm or (b) wordpress>index.php or (c) wp-content>index.php? What would i place in the html field on specific post in admin-mode? Will this overrule the automatic setting? Will update the results....
Niels
2010-05-12 13:48:32
This is something you would implement in the header.php file located in the theme folder you are using. If you are looking to do this for multiple images, than this is not a very practical solution.
hsatterwhite
2010-05-12 14:01:22
You're right. Will delete the 'automatic' setting and call lightbox manually when needed. Would be great if there was a wysywig option in WP to do this. Thanks for your answer!
Niels
2010-05-12 14:05:05
Well you could probably code it very easily in your theme files and rather than using the rel attribute you could use a custom class(es) and delegate lightbox that way.
hsatterwhite
2010-05-12 15:43:44
A:
go into lightbox2.php, and change the following function:
function autoexpand_rel_wlightbox ($content) {
global $post;
if (strpos($content,"<!-- nolightbox -->") == 0) {
$pattern = "/(<a(?![^>]*?rel=['\"]lightbox.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)['\"][^\>]*)>/i";
$replacement = '$1 rel="lightbox['.$post->ID.']">';
$content = preg_replace($pattern, $replacement, $content);
return $content;
} else {
return $content;
}
}
Added - looks for and if it sees it, keeps all links on the page as original :)
Phil
2010-08-17 02:22:39