刚开始最博客 遇到了一些问题

浏览:384 发布日期:2013/08/12 分类:求助交流 关键字: 编辑器 删除 图片
1. 添加博文时 如果没有上传图片,怎么把内容第一张图片设置为缩略图?(我用的是百度编辑器)

2. 删除博文时 把内容里面的图片一并删除 (怎么把内容里面的的图片找出并删除呢?)

3. 载取 内容一部分时 过滤img图片 (我用内容载取函数显示内容时图片也显示了,用什么办法过滤图片呢?)
这是我用的代码:function msubstr($str, $start=0, $length, $charset="utf-8", $suffix=true){
    if(function_exists("mb_substr")) {
      if($suffix){
         if($str==mb_substr($str, $start, $length, $charset)){ 
         
            return mb_substr($str, $start, $length, $charset); 
         }
         else{
         
            return mb_substr($str, $start, $length, $charset)."..."; 
         }  
 }
        else{  
 
     return mb_substr($str, $start, $length, $charset);
    }
    }
    elseif(function_exists('iconv_substr')) {
      if($suffix){
    
         if($str==iconv_substr($str,$start,$length,$charset)){ 
         
            return iconv_substr($str,$start,$length,$charset); 
         }
         else{
         
            return iconv_substr($str,$start,$length,$charset)."..."; 
         } 
     }
        else{  
 
     return iconv_substr($str,$start,$length,$charset);
    }
    }
    $re['utf-8']   = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
    $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";
    $re['gbk']    = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";
    $re['big5']   = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/";
    preg_match_all($re[$charset], $str, $match);
    $slice = join("",array_slice($match[0], $start, $length));
    if($suffix) return $slice."…";
    return $slice;
}
谢谢!
最佳答案
评论( 相关
后面还有条评论,点击查看>>