Skip to content
Closed
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
47af679
thumbs up
dgrammatiko Jan 3, 2022
a91a482
Update plugins/filesystem/local/src/Adapter/LocalAdapter.php
dgrammatiko Jan 3, 2022
32e830b
CS
dgrammatiko Jan 3, 2022
61b7c09
Fix windows FS
dgrammatiko Jan 3, 2022
ab78242
Deal with the thumbs on delete/save
dgrammatiko Jan 3, 2022
4e7595e
oopsy
dgrammatiko Jan 3, 2022
6fa87d4
cs
dgrammatiko Jan 3, 2022
4d809d3
Cs
dgrammatiko Jan 3, 2022
419f3c4
go
dgrammatiko Jan 3, 2022
86b12aa
meh
dgrammatiko Jan 3, 2022
f625e4b
meh
dgrammatiko Jan 3, 2022
0c7c523
meh
dgrammatiko Jan 3, 2022
c301e4b
Expose the thumbs option
dgrammatiko Jan 4, 2022
071ebc0
Use the media/cache folder
dgrammatiko Jan 4, 2022
e582a28
Merge branch '4.1-dev' into 4.1-devlocal-adapter-thumbs
dgrammatiko Jan 4, 2022
ab64d9f
Update plugins/filesystem/local/local.xml
dgrammatiko Jan 7, 2022
92b88c3
Update plugins/filesystem/local/src/Adapter/LocalAdapter.php
dgrammatiko Jan 7, 2022
8059d5a
Update plugins/filesystem/local/src/Adapter/LocalAdapter.php
dgrammatiko Jan 7, 2022
97efd55
fixit
dgrammatiko Jan 9, 2022
fd45914
also the args here
dgrammatiko Jan 9, 2022
7f33dbb
Merge branch '4.1-dev' into 4.1-devlocal-adapter-thumbs
dgrammatiko Jan 9, 2022
666be48
CS
dgrammatiko Jan 9, 2022
d863939
Merge branch '4.1-devlocal-adapter-thumbs' of github.com:dgrammatiko/…
dgrammatiko Jan 9, 2022
7e80d89
Failing tests
dgrammatiko Jan 9, 2022
d3fd272
fix the thumbs
dgrammatiko Jan 13, 2022
6e5027d
Merge pull request #9 from dgrammatiko/patch-12
dgrammatiko Jan 13, 2022
fd82dfa
Fix the thumbs
dgrammatiko Jan 13, 2022
4fba529
oops
dgrammatiko Jan 13, 2022
d3998c3
CS
dgrammatiko Jan 13, 2022
b5c3f4f
oops the paths are wrong
dgrammatiko Jan 13, 2022
f5806e8
Update local.php
dgrammatiko Jan 13, 2022
78f7971
Update libraries/src/Image/Image.php
dgrammatiko Jan 13, 2022
7e73794
Update plugins/filesystem/local/src/Adapter/LocalAdapter.php
dgrammatiko Jan 13, 2022
ecf9a11
Update plugins/filesystem/local/src/Adapter/LocalAdapter.php
dgrammatiko Jan 13, 2022
63bccbb
Only images can have thumbs
dgrammatiko Jan 13, 2022
b1221c1
this is faster
dgrammatiko Jan 13, 2022
785dc5a
Maybe
dgrammatiko Jan 14, 2022
090bb6a
nope
dgrammatiko Jan 14, 2022
3500626
Update libraries/src/Image/Image.php
dgrammatiko Jan 15, 2022
b499429
Keep the old Image createThumbs fn and introduce a new one
dgrammatiko Jan 15, 2022
906c04d
Update libraries/src/Image/Image.php
dgrammatiko Jan 15, 2022
900119b
Merge branch '4.1-dev' into 4.1-devlocal-adapter-thumbs
dgrammatiko Jan 15, 2022
f2a4313
Merge branch '4.1-dev' into 4.1-devlocal-adapter-thumbs
dgrammatiko Jan 16, 2022
cd114cc
Update Image.php
dgrammatiko Jan 16, 2022
b3df15d
Update Image.php
dgrammatiko Jan 16, 2022
cf2824b
maybe
dgrammatiko Jan 16, 2022
30aa1a0
Node fn names don't work on PHP. Well...
dgrammatiko Jan 16, 2022
8e6e915
ihniwid
dgrammatiko Jan 16, 2022
250c5c9
nope
dgrammatiko Jan 16, 2022
87517b7
Make a note so others don't have to waste hours debugging this
dgrammatiko Jan 16, 2022
af9df1b
don't
dgrammatiko Jan 16, 2022
eec4a93
CS
dgrammatiko Jan 16, 2022
a69a231
paths again
dgrammatiko Jan 16, 2022
e1f768b
maybe
dgrammatiko Jan 16, 2022
d54e485
maybe not
dgrammatiko Jan 16, 2022
a349fce
mute failed test
dgrammatiko Jan 16, 2022
beb1a40
maybe realpath is not the right approach here
dgrammatiko Jan 16, 2022
da45a4a
and this
dgrammatiko Jan 16, 2022
43c068b
Update plugins/filesystem/local/src/Adapter/LocalAdapter.php
dgrammatiko Jan 17, 2022
4de5af0
simplified
dgrammatiko Jan 17, 2022
77eddd5
Merge branch '4.2-dev' into 4.1-devlocal-adapter-thumbs
richard67 Feb 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions administrator/language/en-GB/plg_filesystem_local.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
PLG_FILESYSTEM_LOCAL="FileSystem - Local"
PLG_FILESYSTEM_LOCAL_DEFAULT_NAME="Local"
PLG_FILESYSTEM_LOCAL_DIRECTORIES_DIRECTORY_LABEL="Select directories"
PLG_FILESYSTEM_LOCAL_DIRECTORIES_DIRECTORY_THUMBS_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."
43 changes: 35 additions & 8 deletions libraries/src/Image/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,20 @@ 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.
// Make sure the resource handle is valid.
if (!$this->isLoaded())
{
throw new \LogicException('No valid image was loaded.');
Expand Down Expand Up @@ -365,8 +366,16 @@ 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;
Expand All @@ -383,6 +392,24 @@ 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
*/
public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE)
{
$this->createThumbnails($thumbSizes, $creationMethod, false);
}

/**
* Method to crop the current image.
*
Expand Down
12 changes: 10 additions & 2 deletions plugins/filesystem/local/local.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getDisplayName()
public function getAdapters()
{
$adapters = [];
$directories = $this->params->get('directories', '[{"directory": "images"}]');
$directories = $this->params->get('directories', '[{"directory": "images", "thumbs": 1}]');

// Do a check if default settings are not saved by user
// If not initialize them manually
Expand All @@ -95,8 +95,16 @@ public function getAdapters()
$directoryPath = JPATH_ROOT . '/' . $directoryEntity->directory;
$directoryPath = rtrim($directoryPath) . '/';

if (!isset($directoryEntity->thumbs))
{
$directoryEntity->thumbs = 1;
}

$adapter = new \Joomla\Plugin\Filesystem\Local\Adapter\LocalAdapter(
$directoryPath, $directoryEntity->directory
$directoryPath,
$directoryEntity->directory,
$directoryEntity->thumbs,
[200, 200]
);

$adapters[$adapter->getAdapterName()] = $adapter;
Expand Down
11 changes: 11 additions & 0 deletions plugins/filesystem/local/local.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@
hide_none="true"
validate="options"
/>
<field
name="thumbs"
type="radio"
label="PLG_FILESYSTEM_LOCAL_DIRECTORIES_DIRECTORY_THUMBS_LABEL"
layout="joomla.form.field.radio.switcher"
default="1"
filter="integer"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</form>
</field>
</fieldset>
Expand Down
Loading