Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
Added crop and resize image resize method as default resize, fixed add new site automatic host generation from name
givanz397849c41382
diff --git a/admin/controller/settings/site.php b/admin/controller/settings/site.phpindex 8748910..3b8698b 100755--- a/admin/controller/settings/site.php+++ b/admin/controller/settings/site.php@@ -256,7 +256,7 @@ class Site extends Base {$view->set($data);$view->site = $site + $setting;$view->setting = $setting;- $view->resize = ['s' => __('Stretch'), 'c' => __('Crop')];+ $view->resize = ['cs' => __('Crop & Resize'), 's' => __('Stretch'), 'c' => __('Crop')];$view->themeList = $themeList;$view->templateList = \Vvveb\getTemplateList(false, ['email']);diff --git a/install/sql/insert/site/site.sql b/install/sql/insert/site/site.sqlindex b9815c1..a5ddac0 100755--- a/install/sql/insert/site/site.sql+++ b/install/sql/insert/site/site.sql@@ -1,2 +1,2 @@INSERT INTO `site` (`site_id`, `key`, `name`, `host`, `theme`, `template`, `settings`) VALUES-(1, 'default','Default','*.*.*', 'landing', '', '{"description":{"1":{"title": "Vvveb","description": "The next generation website builder","meta-keywords": "cms, page builder, drag and drop, ecommerce, ecommerce platform, designer, developer, php, bootstrap 5","meta-description": "Powerful and easy to use drag and drop website builder for blogs, presentation or ecommerce stores","phone-number": "+55 (111) 123 777"}},"address":"West 21st Street Brooklyn NY","admin-email":"[email protected]","contact-email":"[email protected]","logo":"logo.png","logo-sticky":"logo.png","logo-dark":"logo-white.png","logo-dark-sticky":"logo-white.png","favicon":"favicon.ico","post_large_width":"800","post_large_height":"0","post_medium_width":"400","post_medium_height":"0","post_thumb_width":"150","post_thumb_height":"0","product_large_width":"800","product_large_height":"0","product_medium_width":"400","product_medium_height":"0","product_thumb_width":"150","product_thumb_height":"0","date_format":"F j, Y","time_format":"g:i A", "country_id":"223","region_id":"3655","language_id":"1","currency_id":"1","language":"en_US","currency":"USD","invoice_format":"I-{year2}-{month}-{order_id}-{user_id}-{customer_order_id}","order_id_format":"{rand-str-12}-{year2}","language_id":"1","currency_id":"1","length_type_id":"1","weight_type_id":"1","order_status_id":"1"}');\ No newline at end of file+(1, 'default','Default','*.*.*', 'landing', '', '{"description":{"1":{"title": "Vvveb","description": "The next generation website builder","meta-keywords": "cms, page builder, drag and drop, ecommerce, ecommerce platform, designer, developer, php, bootstrap 5","meta-description": "Powerful and easy to use drag and drop website builder for blogs, presentation or ecommerce stores","phone-number": "+55 (111) 123 777"}},"address":"West 21st Street Brooklyn NY","admin-email":"[email protected]","contact-email":"[email protected]","logo":"logo.png","logo-sticky":"logo.png","logo-dark":"logo-white.png","logo-dark-sticky":"logo-white.png","favicon":"favicon.ico","post_large_width":"800","post_large_height":"450","post_medium_width":"400","post_medium_height":"225","post_thumb_width":"150","post_thumb_height":"84","product_large_width":"800","product_large_height":"1021","product_medium_width":"400","product_medium_height":"510","product_thumb_width":"150","product_thumb_height":"190","date_format":"F j, Y","time_format":"g:i A", "country_id":"223","region_id":"3655","language_id":"1","currency_id":"1","language":"en_US","currency":"USD","invoice_format":"I-{year2}-{month}-{order_id}-{user_id}-{customer_order_id}","order_id_format":"{rand-str-12}-{year2}","language_id":"1","currency_id":"1","length_type_id":"1","weight_type_id":"1","order_status_id":"1"}');\ No newline at end of filediff --git a/public/admin/default b/public/admin/defaultindex befd132..dbb380e 160000--- a/public/admin/default+++ b/public/admin/default@@ -1 +1 @@-Subproject commit befd1325633ffc5d28c5748aee66617b3d3b9b33+Subproject commit dbb380e9f0ee7e7b72fdc4917e63786ddeeaf116diff --git a/system/images.php b/system/images.phpindex 3e45290..9ea72c1 100755--- a/system/images.php+++ b/system/images.php@@ -46,7 +46,7 @@ class Images {return $img->save($dest);}- static public function image($image, $type = '', $size = '', $method = 's') {+ static public function image($image, $type = '', $size = '', $method = 'cs') {$publicPath = \Vvveb\publicUrlPath();list($publicPath, $type, $image, $size) =@@ -74,10 +74,10 @@ class Images {$site = siteSettings();$width = $site["{$type}_{$size}_width"] ?? 0;$height = $site["{$type}_{$size}_height"] ?? 0;- $method = $site["{$type}_{$size}_method"] ?? 's';+ $method = $site["{$type}_{$size}_method"] ?? 'cs';}- $image = self::size($image,"{$width}x{$height}");+ $image = self::size($image,"{$width}x{$height}_$method");if ($width || $height) {if (file_exists(DIR_PUBLIC . $cacheFolder . $image)) {diff --git a/system/media/gd.php b/system/media/gd.phpindex 207948d..903c894 100755--- a/system/media/gd.php+++ b/system/media/gd.php@@ -109,12 +109,32 @@ class Image {}}- public function resize($width, $height, $method = 's') {+ public function resize($width, $height = 0, $method = 's') {+ switch ($method) {+ case 's':+ return $this->stretch($width, $height);++ case 'c':+ return $this->crop($width, $height);++ case 'cs':+ return $this->cropsize($width, $height);+ }+ }++ public function stretch($width, $height = 0) {if (! $this->width || ! $this->height) {return;}if ($width && $height) {+ $scaleW = $width / $this->width;+ $scaleH = $height / $this->height;++ $scale = min($scaleW, $scaleH);++ $width = (int)($this->width * $scale);+ $height = (int)($this->height * $scale);} else {if ($width) {$height = ceil($this->height / ($this->width / $width));@@ -141,4 +161,31 @@ class Image {$this->width = $bottomX - $topX;$this->height = $bottomY - $topY;}++ public function cropsize($width, $height = 0) {+ if (! $this->width || ! $this->height) {+ return;+ }++ $width = $width ?: $height;+ $height = $height ?: $width;++ $newRatio = $width / $height;+ $ratio = $this->width / $this->height;++ if ($newRatio > $ratio) {+ $newWidth = $width;+ $newHeight = floor($width / $this->width * $this->height);+ $crop_x = 0;+ $crop_y = intval(($newHeight - $height) / 2);+ } else {+ $newWidth = floor($height / $this->height * $this->width);+ $newHeight = $height;+ $crop_x = intval(($newWidth - $width) / 2);+ $crop_y = 0;+ }++ $this->image = imagescale($this->image, $newWidth, $newHeight, IMG_BICUBIC_FIXED);+ $this->image = imagecrop($this->image, ['x' => 0, 'y' => 0, 'width' => $width, 'height' => $height]);+ }}diff --git a/system/media/imagick.php b/system/media/imagick.phpindex 293c8b4..9837e9a 100755--- a/system/media/imagick.php+++ b/system/media/imagick.php@@ -38,7 +38,6 @@ class Image {$this->file = $file;$this->image = new \Imagick();$this->image->readImage($file);-$this->width = $this->image->getImageWidth();$this->height = $this->image->getImageHeight();$this->mime = $this->image->getFormat();@@ -82,15 +81,35 @@ class Image {return $this->image->writeImage($file);}- public function resize($width = 0, $height = 0, $method = 's') {+ public function resize($width, $height = 0, $method = 's') {if (! $this->width || ! $this->height) {return;}+ switch ($method) {+ case 's':+ return $this->stretch($width, $height);++ case 'c':+ return $this->crop($width, $height);++ case 'cs':+ return $this->cropsize($width, $height);+ }+ }++ public function stretch($width, $height = 0) {//$this->width = $this->image->getImageWidth();//$this->height = $this->image->getImageHeight();if ($width && $height) {+ $scaleW = $width / $this->width;+ $scaleH = $height / $this->height;++ $scale = min($scaleW, $scaleH);++ $width = (int)($this->width * $scale);+ $height = (int)($this->height * $scale);} else {if ($width) {$height = ceil($this->height / ($this->width / $width));@@ -115,4 +134,28 @@ class Image {$this->width = $this->image->getImageWidth();$this->height = $this->image->getImageHeight();}++ public function cropsize($width, $height = 0) {+ $width = $width ?: $height;+ $height = $height ?: $width;++ $newRatio = $width / $height;+ $ratio = $this->width / $this->height;++ if ($newRatio > $ratio) {+ $new_width = $width;+ $new_height = floor($width / $this->width * $this->height);+ $crop_x = 0;+ $crop_y = intval(($new_height - $height) / 2);+ } else {+ $new_width = floor($height / $this->height * $this->width);+ $new_height = $height;+ $crop_x = intval(($new_width - $width) / 2);+ $crop_y = 0;+ }++ $this->image->resizeImage($new_width, $new_height, \Imagick::FILTER_LANCZOS, 1, true);++ $this->image->cropImage($width, $height, $crop_x, $crop_y);+ }}