/" : "
"; $imgHtml .= "
  • {$iconImage}

    {$img['alt']}

    ×
  • "; } } $html = <<
      $imgHtml
    EOF; return $html; } public function single2($folder, $id, $name="data", $file="", $option=[]){ $folder = urlencode($folder); $imgHtml = ""; $option['callback'] = isset($option['callback']) ? $option['callback'] : ""; $option['watermark'] = isset($option['watermark']) ? $option['watermark'] : ""; $option['sizex'] = isset($option['sizex']) ? $option['sizex'] : ""; $option['sizey'] = isset($option['sizey']) ? $option['sizey'] : ""; $position = isset($option['position']) ? $option['position'] : 'local'; if(!$option['callback'] && !empty($file)) { //$img错误!已改$file gq if(!is_array($file)){ $img['url'] = $file; $img['alt'] = ''; }else{ $img = $file; } $iconImage = in_array(fileExt($img['url']), ['jpg', 'png' , 'gif' , 'jpeg' , 'bmp']) ? "
    /
    " : "
    "; $imgHtml .="
  • {$iconImage}

    {$img['alt']}

    ×
  • "; } $html = <<
      $imgHtml
    •  
    EOF; return $html; } /** * 统一多张图片 * @param $folder * @param $id * @param string $name * @param array $imgs * @param null $callBackFun * @return string */ public function multi($id, $name = "data[image]", $imgs = []) { $url = U("/Base/Photos/index"); $imgHtml = ""; if (!empty($imgs)) { foreach ($imgs as $key => $val) { if (is_string($val)) { $img['url'] = $val; $img['alt'] = ''; } else { $img = $val; } $iconImage = in_array(fileExt($img['url']), ['jpg', 'png', 'gif', 'jpeg', 'bmp']) ? "
    /
    " : "
    "; $imgHtml .= "
  • {$iconImage}

    {$img['alt']}

    ×
  • "; } } $html = <<
      $imgHtml
    EOF; return $html; } public function multi2($folder, $id, $name="data[image]", $imgs=[], $option=[]){ $folder = urlencode($folder); $imgHtml = ""; $option['callback'] = isset($option['callback']) ? $option['callback'] : ""; $option['max'] = isset($option['max']) ? $option['max'] : 200; $option['max'] = $option['max']-count($imgs); $option['watermark'] = isset($option['watermark']) ? $option['watermark'] : ""; $option['sizex'] = isset($option['sizex']) ? $option['sizex'] : ""; $option['sizey'] = isset($option['sizey']) ? $option['sizey'] : ""; $position = isset($option['position']) ? $option['position'] : 'local'; $class = isset($option['class']) ? $option['class'] : ""; if(!$option['callback'] && !empty($imgs)) { foreach($imgs as $key=>$val) { if(is_string($val)) { $img['url'] = $val; $img['alt'] = ''; }else{ $img = $val; } $iconImage = in_array(fileExt($img['url']), ['jpg', 'png' , 'gif' , 'jpeg' , 'bmp']) ? "
    /
    " : "
    "; $imgHtml .="
  • {$iconImage}

    {$img['alt']}

    ×
  • "; } } $html = <<
      $imgHtml
    •  
    EOF; return $html; } /** * 统一上传 * @param $text 按钮文字 * @param $folder 上传文件夹 * @param $id id * @param $option 附加选项 */ public function upload($text, $folder, $id, $option = []) { $folder = urlencode($folder); $trigger = $id . '-trigger'; $modal = $id . '-modal'; $select_btn = $id . '-select-btn'; $upload_btn = $id . '-upload-btn'; $uploader = $id . '_uploader'; $url = isset($option['url']) ? $option['url'] : 'empty'; $positon = isset($option['position']) ? $option['position'] : 'local'; $upload_url = "/admin/Base/Attachment/upload?folder=" . $folder ."&position=".$positon; foreach ($option as $key => $val) { $upload_url = $upload_url . '&' . $key . '=' . $val; } $html = <<
    $text
    EOF; return $html; } }