WordPress主题自动给图片添加Alt标签

 

 

/** 自动给图片添加Alt标签 */
function image_alt_tag($content){
    global $post;preg_match_all('/<img (.*?)\/>/', $content, $images);
    if(!is_null($images)) {foreach($images[1] as $index => $value)
    {
        $new_img = str_replace('<img', '<img alt="'.get_the_title().'-'.get_bloginfo('name').'"', $images[0][$index]);
        $content = str_replace($images[0][$index], $new_img, $content);}}
    return $content;
}
add_filter('the_content', 'image_alt_tag', 99999);

 

給TA打賞
共{{data.count}}人
人已打賞
WordPress

给后台文章列表添加缩略图展示

2021-1-6 1:22:36

WordPress

wordpress美化 - 添加右侧悬浮物悬浮窗

2021-1-6 1:26:31

0 Reply AAuthor MManager
    暫無討論,說說你的看法吧
搜索