From 9435391c3ab5afc3d9ed48229199b95c41d84820 Mon Sep 17 00:00:00 2001 From: trendschau Date: Sat, 12 Jul 2025 22:52:56 +0200 Subject: [PATCH] Replace settings instead of merge to remove old settings and key, move image standard size to imageApi and activate individual image settings --- cache/timer.yaml | 2 +- .../Controllers/ControllerApiImage.php | 31 +++++++++++++++++-- system/typemill/Models/Settings.php | 17 +++++++++- system/typemill/settings/system.yaml | 2 +- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/cache/timer.yaml b/cache/timer.yaml index d7a098c..70a5272 100644 --- a/cache/timer.yaml +++ b/cache/timer.yaml @@ -1,2 +1,2 @@ licenseupdate: 1751827655 -refreshnavi: 1752319250 +refreshnavi: 1752352809 diff --git a/system/typemill/Controllers/ControllerApiImage.php b/system/typemill/Controllers/ControllerApiImage.php index f98cd6a..4f401ae 100644 --- a/system/typemill/Controllers/ControllerApiImage.php +++ b/system/typemill/Controllers/ControllerApiImage.php @@ -340,7 +340,9 @@ class ControllerApiImage extends Controller return $response->withHeader('Content-Type', 'application/json')->withStatus(500); } - if(!$media->storeRenditionsToTmp($this->settings['images'])) + $desiredSizes = $this->getDesiredSizes(); + + if(!$media->storeRenditionsToTmp($desiredSizes)) { $response->getBody()->write(json_encode([ 'message' => $media->errors[0], @@ -509,7 +511,7 @@ class ControllerApiImage extends Controller } # set to youtube size - $sizes = $this->settings['images']; + $sizes = $this->getDesiredSizes(); $sizes['live'] = ['width' => 560, 'height' => 315]; if(!$media->storeRenditionsToTmp($sizes)) @@ -574,4 +576,29 @@ class ControllerApiImage extends Controller return $response->withHeader('Content-Type', 'application/json')->withStatus(500); } + + private function getDesiredSizes() + { + $desiredSizes = [ + 'live' => [ + 'width' => 820, + ], + 'thumbs' => [ + 'width' => 250, + 'height' => 150, + ], + ]; + if(isset($this->settings['liveimagewidth']) && is_int($this->settings['liveimagewidth']) && $this->settings['liveimagewidth'] > 10) + { + $desiredSizes['live']['width'] = $this->settings['liveimagewidth']; + } + if(isset($this->settings['liveimageheight']) && is_int($this->settings['liveimageheight']) && $this->settings['liveimageheight'] > 10) + { + $desiredSizes['live']['height'] = $this->settings['liveimageheight']; + } + + # we could check for theme settings here + + return $desiredSizes; + } } diff --git a/system/typemill/Models/Settings.php b/system/typemill/Models/Settings.php index 61aabc3..c227e23 100644 --- a/system/typemill/Models/Settings.php +++ b/system/typemill/Models/Settings.php @@ -179,9 +179,23 @@ class Settings $userSettings[$key1] = $newSettings; $settings = $userSettings; } - # only merge + # replace system settings else { + # keep old plugin and theme settings unless explicitly replaced + $plugins = $newSettings['plugins'] ?? ($userSettings['plugins'] ?? []); + $themes = $newSettings['themes'] ?? ($userSettings['themes'] ?? []); + + # remove them from $newSettings to avoid overwriting twice + unset($newSettings['plugins'], $newSettings['themes']); + + # final combined settings + $settings = array_merge($newSettings, [ + 'plugins' => $plugins, + 'themes' => $themes, + ]); + + /* # merge usersettings with new settings $settings = array_merge($userSettings, $newSettings); @@ -203,6 +217,7 @@ class Settings } } } + */ } if($this->storage->updateYaml('settingsFolder', '', 'settings.yaml', $settings)) diff --git a/system/typemill/settings/system.yaml b/system/typemill/settings/system.yaml index 947c920..76ab9ca 100644 --- a/system/typemill/settings/system.yaml +++ b/system/typemill/settings/system.yaml @@ -346,7 +346,7 @@ fieldsetai: description: "Select the AI model you want to use. Pricing may vary over time, so please check the latest details on [OpenAI's pricing page](https://platform.openai.com/docs/pricing)" options: gpt-4.1-nano: 'gpt-4.1-nano ($0.10 / $0.40)' - gpt-4.1-mini: 'gpt-4.1-mini ($0.30 / $1.20)' + gpt-4.1-mini: 'gpt-4.1-mini ($0.40 / $1.60)' gpt-4.1: 'gpt-4.1 ($2.00 / $8.00)' gpt-4o-mini: 'gpt-4o-mini ($0.15 / $0.6)' gpt-4o: 'gpt-4o ($2.50 / $10)'