后台内容模块功能完善

This commit is contained in:
2020-03-31 16:17:45 +08:00
parent de73484cca
commit 85d33da0d4
24 changed files with 386 additions and 251 deletions

View File

@@ -157,4 +157,28 @@ function format_bytes($size, $delimiter = '') {
}
return round($size, 2) . $delimiter . $units[$i];
}
/**
* 获取文档封面图片
* @param int $cover_id
* @param string $field
* @return 完整的数据 或者 指定的$field字段值
* @author huajie <banhuajie@163.com>
*/
function get_cover($cover_id, $field = null) {
if (empty($cover_id)) {
return BASE_PATH . '/static/images/default.png';
}
$base_path = "";
$picture = \think\facade\Db::name('Picture')->where(array('status' => 1, 'id' => $cover_id))->find();
if ($field == 'path') {
if (!empty($picture['url'])) {
$picture['path'] = $picture['url'] ? $base_path . $picture['url'] : $base_path . '/static/images/default.png';
} else {
$picture['path'] = $picture['path'] ? $base_path . $picture['path'] : $base_path . '/static/images/default.png';
}
}
return empty($field) ? $picture : $picture[$field];
}