默认情况下,图片上传的时候叫什么名字,alt里面就是什么…
为了SEO有时都要手动把里面改成想要的,比如标题
现在使用字段处理函数来ref="https://xwenw.com/tag/%e8%a7%a3%e5%86%b3" target="_blank">解决
把一下代码放入e/userfun.php文件里面

//替换正文IMG里的ALT内容   
function user_imgalt($mid,$f,$isadd,$isq,$value,$cs){   
    $title=$_POST['title'];   
    $htmls=$value;   
    $pattern = "/<img[^>]+>/";    
    preg_match_all($pattern, $htmls, $matches);    
    for ($i=0; $i<=count($matches[0]); $i++) {   
       preg_match_all("/alt=".+?"/",$matches[0][$i],$altimg);    
        $t_alt=count($altimg[0]);   
        if($t_alt==0){   
            $htmls=str_replace("<img","<img alt="{$title}"",$htmls);   
        }else{   
            $htmls=str_replace($altimg[0][0],"alt="{$title}"",$htmls);   
        }   
    }      
        return $htmls;   
}   
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。