Created
May 19, 2013 11:32
-
-
Save WebEndevSnippets/5607414 to your computer and use it in GitHub Desktop.
WordPress: Add rel tag to links for Lightbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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