Last active
August 29, 2015 14:02
-
-
Save chrdesigner/14ab0e9c77ef653a8f75 to your computer and use it in GitHub Desktop.
add rel prettyphoto to all images
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
<?php | |
/* add rel prettyphoto to all images */ | |
function autoadd_rel_prettyPhoto($content) { | |
global $post; | |
$pattern = "/(<a(?![^>]*?data-rel=['\"]prettyPhoto.*)[^>]*?href=['\"][^'\"]+?\.(?:bmp|gif|jpg|jpeg|png)['\"][^\>]*)>/i"; | |
$replacement = '$1 data-rel="prettyPhoto['.$post->ID.']">'; | |
$content = preg_replace($pattern, $replacement, $content); | |
return $content; | |
} | |
add_filter("the_content","autoadd_rel_prettyPhoto"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment