优化上传组件
This commit is contained in:
@@ -229,25 +229,25 @@ function format_bytes($size, $delimiter = '') {
|
||||
* @param string $field
|
||||
* @return 完整的数据 或者 指定的$field字段值
|
||||
*/
|
||||
function get_attach($id, $field = null) {
|
||||
function get_attach($id, $field = false, $is_list = false) {
|
||||
$basePath = request()->domain();
|
||||
if (empty($id)) {
|
||||
return $basePath . '/static/common/images/default.png';
|
||||
}
|
||||
if (false !== strpos($id, ",")) {
|
||||
if (false !== strpos($id, ",") || $is_list) {
|
||||
$map[] = ['id', 'IN', explode(",", $id)];
|
||||
$picture = \think\facade\Db::name('Attach')->where($map)->column("*", "id");
|
||||
$picture = \app\model\Attach::where($map)->column("*", "id");
|
||||
return $picture;
|
||||
}else{
|
||||
$map[] = ['id', '=', $id];
|
||||
$picture = \think\facade\Db::name('Attach')->where($map)->find();
|
||||
$picture = \app\model\Attach::where($map)->find();
|
||||
if ($field == 'path') {
|
||||
if (!empty($picture['url'])) {
|
||||
$picture['path'] = $picture['url'] ? $basePath . $picture['url'] : $basePath . '/static/images/default.png';
|
||||
$picture['path'] = $picture['url'] ? $basePath . $picture['url'] : $basePath . '/static/common/images/default.png';
|
||||
} else {
|
||||
$picture['path'] = $picture['path'] ? $basePath . $picture['path'] : $basePath . '/static/images/default.png';
|
||||
$picture['path'] = $picture['path'] ? $basePath . $picture['path'] : $basePath . '/static/common/images/default.png';
|
||||
}
|
||||
}
|
||||
return empty($field) ? $picture : $picture[$field];
|
||||
return (false !== $field) ? $picture[$field] : $picture;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user