Best way to programatically add “rel” attributes to page and post images

For single posts and pages, I would like to add certain rel attributes to all the images on the contained therein added with the “Add Image” functionality on the edit screen.

The attribute would be rel="lightbox[post id]"

Read More

What function would I filter to accomplish this most effectively?

Related posts

Leave a Reply

2 comments

  1. image_send_to_editor

    function insert_img_rel_attrib( $html, $id, $caption, $title, $align, $url, $size, $alt )
    {
      /* Run your magic on the image $html to insert rel attrib */
      return $html;
    }
    add_filter( 'image_send_to_editor', 'insert_img_rel_attrib' );