Skip to content
Closed
Changes from 1 commit
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
38 changes: 35 additions & 3 deletions plugins/filesystem/local/src/Adapter/LocalAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function updateFile(string $name, string $path, $data)
* @since 4.0.0
* @throws \Exception
*/
public function delete(string $path)
public function delete(string $path): void
{
$localPath = $this->getLocalPath($path);

Expand Down Expand Up @@ -358,8 +358,7 @@ private function getPathInformation(string $path): \stdClass
$obj->width = $props->width;
$obj->height = $props->height;

// Todo : Change this path to an actual thumbnail path
$obj->thumb_path = $this->getUrl($obj->path);
$obj->thumb_path = $this->getThumb($path);
}
catch (UnparsableImageException $e)
{
Expand Down Expand Up @@ -869,4 +868,37 @@ private function getLocalPath(string $path): string
throw new InvalidPathException($e->getMessage());
}
}

/**
* Returns the path for the thumbnail of the given path.
* If the thumbnail does not exist, it will be created.
*
* @param string $path The path of the image
*
* @return string
*
* @since __DEPLOY_VERSION__
*/
private function getThumb($path): string
{
$dir = \dirname(str_replace(JPATH_ROOT . '/' . $this->filePath, JPATH_ROOT . '/media/cache_mm/thumbs/' . $this->filePath, $path));

if (!is_dir($dir))
{
mkdir($dir, 0755, true);
}

$thumbPath = str_replace(JPATH_ROOT . '/' . $this->filePath, JPATH_ROOT . '/media/cache_mm/thumbs/' . $this->filePath, $path);
$thumbURL = Uri::root() . $this->getEncodedPath(str_replace(JPATH_ROOT . '/' . $this->filePath, 'media/cache_mm/thumbs/' . $this->filePath, $path));

if (file_exists($thumbPath))
{
return $thumbURL;
}

// Create the thumbnail
(new Image($path))->resize(300, 200, true)->toFile($thumbPath);

return $thumbURL;
}
}