commit 9ef0ce3fb55dd7ac43e96e614c904c9c86305abc
parent 707e8da6f57eeeb731608371a2ea3eb1096f2e1d
Author: markseu <mark2011@mayberg.se>
Date: Tue, 23 Apr 2024 12:11:59 +0200
Updated image upload for Robert
Diffstat:
5 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/system/extensions/update-available.ini b/system/extensions/update-available.ini
@@ -148,14 +148,14 @@ system/themes/copenhagen.css: copenhagen.css, create, update, careful
system/themes/copenhagen.png: copenhagen.png, create
Extension: Core
-Version: 0.9.4
+Version: 0.9.5
Description: Core functionality of your website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-core
DocumentationLanguage: en, de, sv
-Published: 2024-04-21 11:10:25
+Published: 2024-04-23 10:16:44
Status: available
system/workers/core.php: core.php, create, update
system/extensions/core.php: coreupdate.txt, update
@@ -212,14 +212,14 @@ Status: available
system/workers/dutch.php: dutch.php, create, update
Extension: Edit
-Version: 0.9.4
+Version: 0.9.5
Description: Edit your website in a web browser.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-edit
DocumentationLanguage: en, de, sv
-Published: 2024-04-20 15:10:16
+Published: 2024-04-23 11:37:34
Status: available
system/workers/edit.php: edit.php, create, update
system/workers/edit.css: edit.css, create, update
@@ -431,14 +431,14 @@ system/workers/icon.css: icon.css, create, update
system/workers/icon.woff: icon.woff, create, update
Extension: Image
-Version: 0.9.2
+Version: 0.9.3
Description: Add images and thumbnails.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-image
DocumentationLanguage: en, de, sv
-Published: 2024-04-20 15:25:01
+Published: 2024-04-23 11:44:38
Status: available
system/workers/image.php: image.php, create, update
media/images/photo.jpg: photo.jpg, create, optional
diff --git a/system/extensions/yellow-extension.ini b/system/extensions/yellow-extension.ini
@@ -1,14 +1,14 @@
# Datenstrom Yellow extension settings
Extension: Core
-Version: 0.9.4
+Version: 0.9.5
Description: Core functionality of your website.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-core/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-core
DocumentationLanguage: en, de, sv
-Published: 2024-04-21 11:10:25
+Published: 2024-04-23 10:16:44
Status: available
system/workers/core.php: core.php, create, update
system/extensions/core.php: coreupdate.txt, update
@@ -20,14 +20,14 @@ system/layouts/navigation.html: navigation.html, create, update, careful
system/layouts/pagination.html: pagination.html, create, update, careful
Extension: Edit
-Version: 0.9.4
+Version: 0.9.5
Description: Edit your website in a web browser.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-edit/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-edit
DocumentationLanguage: en, de, sv
-Published: 2024-04-20 15:10:16
+Published: 2024-04-23 11:37:34
Status: available
system/workers/edit.php: edit.php, create, update
system/workers/edit.css: edit.css, create, update
@@ -48,14 +48,14 @@ Status: available
system/workers/generate.php: generate.php, create, update
Extension: Image
-Version: 0.9.2
+Version: 0.9.3
Description: Add images and thumbnails.
Developer: Anna Svensson
Tag: feature
DownloadUrl: https://github.com/annaesvensson/yellow-image/archive/refs/heads/main.zip
DocumentationUrl: https://github.com/annaesvensson/yellow-image
DocumentationLanguage: en, de, sv
-Published: 2024-04-20 15:25:01
+Published: 2024-04-23 11:44:38
Status: available
system/workers/image.php: image.php, create, update
media/images/photo.jpg: photo.jpg, create, optional
diff --git a/system/workers/core.php b/system/workers/core.php
@@ -2,7 +2,7 @@
// Core extension, https://github.com/annaesvensson/yellow-core
class YellowCore {
- const VERSION = "0.9.4";
+ const VERSION = "0.9.5";
const RELEASE = "0.9";
public $content; // content files
public $media; // media files
@@ -2244,6 +2244,11 @@ class YellowToolbox {
return $deleted;
}
+ // Return file size
+ public function getFileSize($fileName) {
+ return is_file($fileName) ? filesize($fileName) : 0;
+ }
+
// Return file type
public function getFileType($fileName) {
return strtoloweru(($pos = strrposu($fileName, ".")) ? substru($fileName, $pos+1) : "");
@@ -3073,7 +3078,7 @@ class YellowPage {
if ($this->get("status")=="shared") $this->available = false;
if ($this->get("status")=="unlisted") $this->visible = false;
} else {
- $this->set("size", filesize($this->fileName));
+ $this->set("size", $this->yellow->toolbox->getFileSize($this->fileName));
$this->set("type", $this->yellow->toolbox->getFileType($this->fileName));
$this->set("group", $this->yellow->toolbox->getFileGroup($this->fileName, $this->yellow->system->get("coreMediaDirectory")));
$this->set("modified", date("Y-m-d H:i:s", $this->yellow->toolbox->getFileModified($this->fileName)));
diff --git a/system/workers/edit.php b/system/workers/edit.php
@@ -2,7 +2,7 @@
// Edit extension, https://github.com/annaesvensson/yellow-edit
class YellowEdit {
- const VERSION = "0.9.4";
+ const VERSION = "0.9.5";
public $yellow; // access to API
public $response; // web response
public $merge; // text merge
@@ -1083,6 +1083,7 @@ class YellowEditResponse {
if ($this->yellow->content->find($page->location)) {
$page->location = $this->getPageNewLocation($page->rawData, $page->location, $page->get("editNewLocation"));
$page->fileName = $this->getPageNewFile($page->location, $page->fileName, $page->get("published"));
+ $pageCounter = 0;
while ($this->yellow->content->find($page->location) || is_string_empty($page->fileName)) {
$page->rawData = $this->yellow->toolbox->setMetaData($page->rawData, "title", $this->getTitleNext($page->rawData));
$page->rawData = $this->yellow->lookup->normaliseLines($page->rawData, $endOfLine);
@@ -1175,10 +1176,10 @@ class YellowEditResponse {
// Return uploaded file
public function getFileUpload($scheme, $address, $base, $pageLocation, $fileNameTemp, $fileNameShort) {
$file = new YellowPage($this->yellow);
- $file->setRequestInformation($scheme, $address, $base, "/".$fileNameTemp, $fileNameTemp, false);
+ $file->setRequestInformation($scheme, $address, $base, "/".$fileNameShort, $fileNameShort, false);
$file->parseMeta(null);
+ $file->set("fileNameTemp", $fileNameTemp);
$file->set("fileNameShort", $fileNameShort);
- $file->set("type", $this->yellow->toolbox->getFileType($fileNameShort));
if ($file->get("type")=="html" || $file->get("type")=="svg") {
$fileData = $this->yellow->toolbox->readFile($fileNameTemp);
$fileData = $this->yellow->lookup->normaliseData($fileData, $file->get("type"));
@@ -1187,8 +1188,10 @@ class YellowEditResponse {
}
}
$this->editMediaFile($file, "upload", $this->userEmail);
+ $fileNameShort = basename($file->fileName);
$file->location = $this->getFileNewLocation($fileNameShort, $pageLocation, $file->get("fileNewLocation"));
$file->fileName = substru($file->location, 1);
+ $fileCounter = 0;
while (is_file($file->fileName)) {
$fileNameShort = $this->getFileNext(basename($file->fileName));
$file->location = $this->getFileNewLocation($fileNameShort, $pageLocation, $file->get("fileNewLocation"));
diff --git a/system/workers/image.php b/system/workers/image.php
@@ -2,7 +2,7 @@
// Image extension, https://github.com/annaesvensson/yellow-image
class YellowImage {
- const VERSION = "0.9.2";
+ const VERSION = "0.9.3";
public $yellow; // access to API
// Handle initialisation
@@ -12,6 +12,7 @@ class YellowImage {
$this->yellow->system->setDefault("imageUploadHeightMax", "1280");
$this->yellow->system->setDefault("imageUploadJpegQuality", "80");
$this->yellow->system->setDefault("imageThumbnailJpegQuality", "80");
+ $this->yellow->system->setDefault("imageJpegExtension", "auto");
}
// Handle update
@@ -54,7 +55,7 @@ class YellowImage {
// Handle media file changes
public function onEditMediaFile($file, $action, $email) {
if ($action=="upload") {
- $fileName = $file->fileName;
+ $fileName = $file->get("fileNameTemp");
list($widthInput, $heightInput, $orientation, $type) =
$this->yellow->toolbox->detectImageInformation($fileName, $file->get("type"));
$widthMax = $this->yellow->system->get("imageUploadWidthMax");
@@ -76,6 +77,10 @@ class YellowImage {
}
}
}
+ if ($type=="jpeg") {
+ $file->fileName = dirname($file->fileName)."/".pathinfo($file->fileName, PATHINFO_FILENAME).$this->getImageExtension($file->fileName, $type);
+ $file->set("type", $this->yellow->toolbox->getFileType($file->fileName));
+ }
}
}
@@ -93,7 +98,7 @@ class YellowImage {
$pathThumb = $this->yellow->lookup->findMediaDirectory("coreThumbnailLocation");
$fileNameThumb = ltrim(str_replace(array("/", "\\", "."), "-", dirname($fileNameShort)."/".pathinfo($fileName, PATHINFO_FILENAME)), "-");
$fileNameThumb .= "-".$widthOutput."x".$heightOutput;
- $fileNameThumb .= ".".pathinfo($fileName, PATHINFO_EXTENSION);
+ $fileNameThumb .= $this->getImageExtension($fileName, $type);
$fileNameOutput = $pathThumb.$fileNameThumb;
if ($this->isFileNotUpdated($fileName, $fileNameOutput)) {
$image = $this->loadImage($fileName, $type);
@@ -121,6 +126,14 @@ class YellowImage {
}
return array(intval($widthOutput), intval($heightOutput));
}
+
+ // Return image extension
+ public function getImageExtension($fileName, $type) {
+ $jpegExtension = $this->yellow->system->get("imageJpegExtension");
+ $fileExtension = ".".pathinfo($fileName, PATHINFO_EXTENSION);
+ if ($jpegExtension!="auto" && $type=="jpeg") $fileExtension = $jpegExtension;
+ return $fileExtension;
+ }
// Load image from file
public function loadImage($fileName, $type) {