From 4f9ffb46f1363d3541547175b48298c4174b8a50 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Thu, 11 Mar 2021 17:35:00 +0300 Subject: [PATCH] watermark settings --- .../resources/config/settings/sections.php | 1 + .../resources/config/settings/settings.php | 60 ++++++++++--------- .../advs-module/resources/lang/en/setting.php | 4 ++ .../src/Http/Controller/UploadController.php | 38 ++++++------ 4 files changed, 58 insertions(+), 45 deletions(-) diff --git a/addons/default/visiosoft/advs-module/resources/config/settings/sections.php b/addons/default/visiosoft/advs-module/resources/config/settings/sections.php index 9222867a3..84f6e8e67 100644 --- a/addons/default/visiosoft/advs-module/resources/config/settings/sections.php +++ b/addons/default/visiosoft/advs-module/resources/config/settings/sections.php @@ -62,6 +62,7 @@ return [ 'ads_image' => [ 'title' => 'visiosoft.module.advs::section.ads_image', 'fields' => [ + 'watermark', 'image_resize_backend', 'full_image_width', 'full_image_height', diff --git a/addons/default/visiosoft/advs-module/resources/config/settings/settings.php b/addons/default/visiosoft/advs-module/resources/config/settings/settings.php index dded12c5b..467bf61e8 100644 --- a/addons/default/visiosoft/advs-module/resources/config/settings/settings.php +++ b/addons/default/visiosoft/advs-module/resources/config/settings/settings.php @@ -295,6 +295,12 @@ return [ 'default_value' => 600, ], ], + 'watermark' => [ + 'type' => 'anomaly.field_type.boolean', + 'config' => [ + 'default_value' => false, + ] + ], 'watermark_type' => [ 'type' => 'anomaly.field_type.select', 'bind' => 'adv.watermark_type', @@ -389,31 +395,31 @@ return [ }, ], ], - 'favicon' => [ - 'type' => 'anomaly.field_type.file', - ], - 'ads_date_hidden' => [ - 'type' => 'anomaly.field_type.boolean', - 'config' => [ - 'default_value' => false, - ] - ], - 'hide_listing_header' => [ - 'type' => 'anomaly.field_type.boolean', - 'config' => [ - 'default_value' => false, - ] - ], - 'hide_filter_section' => [ - 'type' => 'anomaly.field_type.boolean', - 'config' => [ - 'default_value' => false, - ] - ], - 'hide_seller_info' => [ - 'type' => 'anomaly.field_type.boolean', - 'config' => [ - 'default_value' => false, - ] - ] + 'favicon' => [ + 'type' => 'anomaly.field_type.file', + ], + 'ads_date_hidden' => [ + 'type' => 'anomaly.field_type.boolean', + 'config' => [ + 'default_value' => false, + ] + ], + 'hide_listing_header' => [ + 'type' => 'anomaly.field_type.boolean', + 'config' => [ + 'default_value' => false, + ] + ], + 'hide_filter_section' => [ + 'type' => 'anomaly.field_type.boolean', + 'config' => [ + 'default_value' => false, + ] + ], + 'hide_seller_info' => [ + 'type' => 'anomaly.field_type.boolean', + 'config' => [ + 'default_value' => false, + ] + ] ]; diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/setting.php b/addons/default/visiosoft/advs-module/resources/lang/en/setting.php index 01f5e9639..823d2589a 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/setting.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/setting.php @@ -247,4 +247,8 @@ return [ 'name' => 'GET Categories', 'instructions' => 'It represents the categories in which the GET property will be valid.' ], + 'watermark' => [ + 'name' => 'Watermark', + 'instructions' => 'Is watermark active?' + ], ]; diff --git a/addons/default/visiosoft/media-field_type/src/Http/Controller/UploadController.php b/addons/default/visiosoft/media-field_type/src/Http/Controller/UploadController.php index 0fdc0bdf4..7ad894ff6 100644 --- a/addons/default/visiosoft/media-field_type/src/Http/Controller/UploadController.php +++ b/addons/default/visiosoft/media-field_type/src/Http/Controller/UploadController.php @@ -118,26 +118,28 @@ class UploadController extends AdminController foreach ($image_types as $key => $image) { - if ($settings_value['watermark_type'] == 'image') { + if (setting_value('visiosoft.module.advs::watermark', false)) { + if ($settings_value['watermark_type'] == 'image') { + + if ($watermarkimage = $this->files->find($settings_value['watermark_image'])) { + $watermark = WaterMark::make(app_storage_path() . '/files-module/local/' . $watermarkimage->path()); + $image->insert($watermark, $settings_value['watermark_position']); + } + + } else { + $v = "top"; + $h = "center"; + $w = $image->width() / 2; + $h1 = $image->height() / 2; + $font_size = $w / 20; + $image->text(($watermark_text = setting_value('visiosoft.module.advs::watermark_text')) ? $watermark_text : 'Openclassify', $w, $h1, function ($font) use ($v, $h, $font_size) { + $font->file(public_path('Antonio-Bold.ttf')); + $font->size($font_size); + $font->align($h); + $font->valign($v); + }); - if ($watermarkimage = $this->files->find($settings_value['watermark_image'])) { - $watermark = WaterMark::make(app_storage_path() . '/files-module/local/' . $watermarkimage->path()); - $image->insert($watermark, $settings_value['watermark_position']); } - - } else { - $v = "top"; - $h = "center"; - $w = $image->width() / 2; - $h1 = $image->height() / 2; - $font_size = $w / 20; - $image->text(($watermark_text = setting_value('visiosoft.module.advs::watermark_text')) ? $watermark_text : 'Openclassify', $w, $h1, function ($font) use ($v, $h, $font_size) { - $font->file(public_path('Antonio-Bold.ttf')); - $font->size($font_size); - $font->align($h); - $font->valign($v); - }); - } if ($key === "full") {