fix: 上传图片水印

This commit is contained in:
2025-06-11 17:09:41 +08:00
parent 8ccd881677
commit 256c0d72f2

View File

@@ -155,27 +155,32 @@ class Upload
{
$config_model = new \app\admin\controller\v1\SiteConfig;
$watermark_config = $config_model->getByGroupUniqueLabel('watermark');
$opacity = data_get($watermark_config, 'watermark_opacity.value', 100);
if ($opacity == '') {
$opacity = 100;
}
return [
'enabled' => data_get($watermark_config, 'watermark_enabled.value', 0) == 1,
'type' => data_get($watermark_config, 'watermark_type.value', ''),
'text_options' => [
'txt' => data_get($watermark_config, 'watermark_text_value.value', ''),
'font' => data_get($watermark_config, 'watermark_text_font.value', ''),
'size' => (float)data_get($watermark_config, 'watermark_text_size.value', 12),
'color' => data_get($watermark_config, 'watermark_text_color.value', '#000000'),
'position' => data_get($watermark_config, 'watermark_position.value', 'top-left'),
'size' => (float)data_get($watermark_config, 'watermark_text_size.value', 12)?:12,
'color' => data_get($watermark_config, 'watermark_text_color.value', '#000000')?:'#000000',
'position' => data_get($watermark_config, 'watermark_position.value', 'top-left')?:'top-left',
'offset_x' => (int)data_get($watermark_config, 'watermark_offset_x.value', 0),
'offset_y' => (int)data_get($watermark_config, 'watermark_offset_y.value', 0),
'opacity' => (int)data_get($watermark_config, 'watermark_opacity.value', 100),
'opacity' => (int)$opacity,
],
'image_options' => [
'image' => data_get($watermark_config, 'watermark_image_value.value', ''),
'width' => (int)data_get($watermark_config, 'watermark_image_width.value')?:null,
'height' => (int)data_get($watermark_config, 'watermark_image_height.value')?:null,
'position' => data_get($watermark_config, 'watermark_position.value', 'top-left'),
'position' => data_get($watermark_config, 'watermark_position.value', 'top-left')?:'top-left',
'offset_x' => (int)data_get($watermark_config, 'watermark_offset_x.value', 0),
'offset_y' => (int)data_get($watermark_config, 'watermark_offset_y.value', 0),
'opacity' => (int)data_get($watermark_config, 'watermark_opacity.value', 100),
'opacity' => (int)$opacity,
]
];
}