Building my first site. Running v3.1.1 with the Boldy theme from Site5.

Boldy makes use of prettyPhoto Lightbox. If you refer to the instructions for setting up Boldy (bottom of page)

For adding Lightbox behaviour to a link just add rel="prettyPhoto" to the image Link Rel enter image description here

I have just imported about 100 blog posts from Wordpress.com.

2 questions (although very related:

  1. How do I batch update all previous pictures to load by default with the prettyPhoto i.e. Apply a 'prettyphoto' tag to each pictures rel.

  2. I have about 15 authors for the blog. I know they will forget to manually set this prettyPhoto tag = Is there a way to make it default to this?

link|improve this question

68% accept rate
feedback

1 Answer

up vote 2 down vote accepted

You can create a content_filter that will update on the fly meaning that you don't have to update all previous pictures and it will be the default so you don't have to worry about your authors. something like this:

function autoadd_rel_prettyPhoto($content) {
    global $post;
    $pattern        = "/(<a(?![^>]*?rel=['\"]prettyPhoto.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)['\"][^\>]*)>/i";
    $replacement    = '$1 rel="prettyPhoto['.$post->ID.']">';
    $content = preg_replace($pattern, $replacement, $content);
    return $content;
}

add_filter("the_content","autoadd_rel_prettyPhoto");
link|improve this answer
sounds perfect. Im a noob. Where do I paste this function into? The functions.php? I assume it does not matter where in that file? – Simon Apr 15 '11 at 4:43
yeah, that function needs to be added to your functions.php file – Piet Apr 15 '11 at 4:46
Sorry did'nt see your comment, yes just copy this code and paste it anywhere in your theme's functions.php file. – Bainternet Apr 15 '11 at 5:47
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.