如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
function thumb($src = '', $width = 500, $height = 500, $type = 1, $replace = false) { $src = './'.$src; if(is_file($src) && file_exists($src)) { $ext = pathinfo($src, PATHINFO_EXTENSION); $name = basename($src, '.'.$ext); $dir = dirname($src); if(in_array($ext, array('gif','jpg','jpeg','bmp','png'))) { $name = $name.'_thumb_'.$width.'_'.$height.'.'.$ext; $file = $dir.'/'.$name; if(!file_exists($file) || $replace == TRUE) { $image = \think\Image::open($src); $image->thumb($width, $height, $type); $image->save($file); } $file=str_replace("\\","/",$file); $file = '/'.trim($file,'./'); return $file; } } $src=str_replace("\\","/",$src); $src = '/'.trim($src,'./'); return $src; }