Apply a tag to every images ‘Link Rel’

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)

Read More

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?

Related posts

Leave a Reply

1 comment

  1. 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");