Created
August 1, 2013 10:05
-
-
Save leavlzi/6130090 to your computer and use it in GitHub Desktop.
// WordPress 为图片自动添加属性
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', 'pirobox_gall_replace'); | |
function pirobox_gall_replace ($content) | |
{ | |
global $post; | |
$pattern = "/<img(.*?)src=('|\")([^>]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)>/i"; | |
$replacement = '<img$1src=$2$3.$4$5 class="img-responsive"$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