Closed joomlapl-bot closed 1 year ago
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/38805 Poniżej zmiany w oryginale:
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/38805 Poniżej zmiany w oryginale:
Click to expand the diff!
```diff diff --git a/administrator/language/en-GB/plg_filesystem_local.ini b/administrator/language/en-GB/plg_filesystem_local.ini index c7b40cb9e941..86fe8999570e 100644 --- a/administrator/language/en-GB/plg_filesystem_local.ini +++ b/administrator/language/en-GB/plg_filesystem_local.ini @@ -5,6 +5,7 @@ PLG_FILESYSTEM_LOCAL="FileSystem - Local" PLG_FILESYSTEM_LOCAL_DEFAULT_NAME="Local" -PLG_FILESYSTEM_LOCAL_DIRECTORIES_DIRECTORY_LABEL="Select directories" +PLG_FILESYSTEM_LOCAL_DIRECTORIES_DIRECTORY_LABEL="Select Directories" +PLG_FILESYSTEM_LOCAL_DIRECTORIES_DIRECTORY_THUMBNAILS_LABEL="Create Thumbnails" PLG_FILESYSTEM_LOCAL_DIRECTORIES_LABEL="Directories" PLG_FILESYSTEM_LOCAL_XML_DESCRIPTION="Filesystem plugin to define one or multiple local directories to store your media files." diff --git a/libraries/src/Image/Image.php b/libraries/src/Image/Image.php index 32b01a766b1e..688ba83b02a5 100644 --- a/libraries/src/Image/Image.php +++ b/libraries/src/Image/Image.php @@ -305,17 +305,18 @@ public function generateThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE /** * Method to create thumbnails from the current image and save them to disk. It allows creation by resizing or cropping the original image. * - * @param mixed $thumbSizes string or array of strings. Example: $thumbSizes = array('150x75','250x150'); - * @param integer $creationMethod 1-3 resize $scaleMethod | 4 create cropping - * @param string $thumbsFolder destination thumbs folder. null generates a thumbs folder in the image folder + * @param mixed $thumbSizes string or array of strings. Example: $thumbSizes = ['150x75','250x150']; + * @param integer $creationMethod 1-3 resize $scaleMethod | 4 create cropping + * @param string $thumbsFolder destination thumbs folder. null generates a thumbs folder in the image folder + * @param boolean $useOriginalName Shall we use the original image name? Defaults is false, {filename}_{width}x{height}.{ext} * * @return array * - * @since 2.5.0 + * @since __DEPLOY_VERSION__ * @throws \LogicException * @throws \InvalidArgumentException */ - public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE, $thumbsFolder = null) + public function createThumbnails($thumbSizes, $creationMethod = self::SCALE_INSIDE, $thumbsFolder = null, $useOriginalName = false) { // Make sure the resource handle is valid. if (!$this->isLoaded()) { @@ -349,8 +350,13 @@ public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE, $thumbWidth = $thumb->getWidth(); $thumbHeight = $thumb->getHeight(); - // Generate thumb name - $thumbFileName = $filename . '_' . $thumbWidth . 'x' . $thumbHeight . '.' . $fileExtension; + if ($useOriginalName) { + // Generate thumb name + $thumbFileName = $filename . '.' . $fileExtension; + } else { + // Generate thumb name + $thumbFileName = $filename . '_' . $thumbWidth . 'x' . $thumbHeight . '.' . $fileExtension; + } // Save thumb file to disk $thumbFileName = $thumbsFolder . '/' . $thumbFileName; @@ -366,6 +372,26 @@ public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE, return $thumbsCreated; } + /** + * Method to create thumbnails from the current image and save them to disk. It allows creation by resizing or cropping the original image. + * + * @param mixed $thumbSizes string or array of strings. Example: $thumbSizes = ['150x75','250x150']; + * @param integer $creationMethod 1-3 resize $scaleMethod | 4 create cropping + * @param string $thumbsFolder destination thumbs folder. null generates a thumbs folder in the image folder + * + * @return array + * + * @since 2.5.0 + * @throws \LogicException + * @throws \InvalidArgumentException + * + * @deprecated 6.0 Use \Joomla\CMS\Image\createThumbnails instead + */ + public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE, $thumbsFolder = null) + { + return $this->createThumbnails($thumbSizes, $creationMethod, $thumbsFolder, false); + } + /** * Method to crop the current image. * diff --git a/plugins/filesystem/local/local.php b/plugins/filesystem/local/local.php index d23ab606b4e1..5f2df57e2131 100644 --- a/plugins/filesystem/local/local.php +++ b/plugins/filesystem/local/local.php @@ -84,7 +84,7 @@ public function getDisplayName() public function getAdapters() { $adapters = []; - $directories = $this->params->get('directories', '[{"directory": "images"}]'); + $directories = $this->params->get('directories', '[{"directory": "images", "thumbs": 0}]'); // Do a check if default settings are not saved by user // If not initialize them manually @@ -97,9 +97,15 @@ public function getAdapters() $directoryPath = JPATH_ROOT . '/' . $directoryEntity->directory; $directoryPath = rtrim($directoryPath) . '/'; + if (!isset($directoryEntity->thumbs)) { + $directoryEntity->thumbs = 0; + } + $adapter = new \Joomla\Plugin\Filesystem\Local\Adapter\LocalAdapter( $directoryPath, - $directoryEntity->directory + $directoryEntity->directory, + $directoryEntity->thumbs, + [200, 200] ); $adapters[$adapter->getAdapterName()] = $adapter; diff --git a/plugins/filesystem/local/local.xml b/plugins/filesystem/local/local.xml index 8f93dc5bc9e2..bcb9a676767f 100644 --- a/plugins/filesystem/local/local.xml +++ b/plugins/filesystem/local/local.xml @@ -44,6 +44,17 @@ hide_none="true" validate="options" /> +