Skip to content

Instantly share code, notes, and snippets.

@WebEndevSnippets
Created May 19, 2013 11:32
Show Gist options
  • Save WebEndevSnippets/5607414 to your computer and use it in GitHub Desktop.
Save WebEndevSnippets/5607414 to your computer and use it in GitHub Desktop.
WordPress: Add rel tag to links for Lightbox
add_filter( 'the_content', 'we_addlightboxrel_replace', 12 );
add_filter( 'get_comment_text', 'we_addlightboxrel_replace' );
/**
* Add rel tag to links for Lightbox
*/
function we_addlightboxrel_replace($content){
global $post;
$pattern = "/<a(.*?)href=('|\")([^>]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)<\/a>/i";
$replacement = '<a$1href=$2$3.$4$5 rel="prettyPhoto"$6>$7';
$content = preg_replace($pattern, $replacement, $content);
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment