getThumb()获取缩略图函数 * * * * * ~~~ /** * @param $file_path * @param int $type 1:返回缩略图,2:缩小正方图,3:原图 * @return mixed|null|string * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ function getThumb($file_path, $type = 1) { $array = explode('/', $file_path); $Name = end($array); $model = new \app\common\model\Picture(); $info = $model->where('name', $Name)->cache(true)->find(); if (!$info) { return null; } $file = ''; switch ($type) { case 1: $file = $info['thumb']; break; case 2: $file = $info['reduce']; break; case 3: $file = $info['picture']; break; } return getHostDomain() . DS . $file; } ~~~