-1

我想将我所有的 wordpress 帖子图片链接链接到:http ://www.simafun.com除了一些图片。

所以我用找到这个代码:

<?php
function wpguy_linked_image($content){

    $searchfor = '/(<img[^>]*\/>)/';
    $replacewith = '<a target="_blank" href="'.get_permalink().'">$1</a>';

    {
        $content = preg_replace($searchfor, $replacewith, $content, -1);
    }
    return $content;
}

add_filter('the_content', 'wpguy_linked_image');
?>

它替换了所有图片链接,但不删除图片的上一个链接。

  1. 我首先删除上一个链接。例如:我的图片链接到自己“http://www.up.simafun.com/2013/01/police-tabriz-1.jpg”,然后用我的网站名称(http://www.simafun.com )

  2. 我想从更改链接中排除一些图片,例如链接到下载的图片(例如:“http://up.simafun.com/download-simafun.com.gif”)

请原谅我的英语不好。

4

1 回答 1

0

就用这个:

$html = preg_replace("/<img.*src="(.*?)".*\/?>/",'<img src="http://up.simafun.com/download-simafun.com.gif">',$html );
于 2013-01-09T13:36:28.607 回答