Skip to content

Commit

Permalink
filemanager 2.3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkounay committed Jan 4, 2022
1 parent f12d215 commit 22d02be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions Controller/CropController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function ajaxCrop(Request $request): JsonResponse
$extension = $pathinfo['extension'];

if ($src[0] === '/') {
$src = urldecode($this->getParameter('kernel.project_dir').'/'.$fileManager['web_dir'].$src);
$src = urldecode($fileManager['web_dir'].$src);
}

if (!file_exists($src)) {
Expand All @@ -72,19 +72,17 @@ public function ajaxCrop(Request $request): JsonResponse
if (substr($destinationFolder, -1) !== DIRECTORY_SEPARATOR) {
$destinationFolder .= DIRECTORY_SEPARATOR;
}
$rootdir = $this->getParameter('kernel.project_dir') . '/src';

$baseUrl = $rootdir . ' ../' . $fileManager['web_dir'];
$cropStrAdd = '_crop_';
$filename = $pathinfo['filename'];
$cropPos = mb_strpos($filename, $cropStrAdd);
if ($cropPos !== false) {
$filename = mb_substr($filename, 0, $cropPos);
}
$croppedPath = $this->getParameter('ux_media')['cropped_path'];
$savedPath = $image->save($rootdir . DIRECTORY_SEPARATOR . $destinationFolder . $croppedPath . urldecode($filename) . $cropStrAdd . uniqid() . '.' . $extension, 'guess', 85);
$savedPath = $image->save($destinationFolder . $croppedPath . urldecode($filename) . $cropStrAdd . uniqid() . '.' . $extension, 'guess', 85);

$savedPath = mb_substr($savedPath, mb_strlen($baseUrl));
$savedPath = mb_substr($savedPath, mb_strlen($fileManager['web_dir']));
if ($savedPath[0] !== '/') {
$savedPath = $src;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"symfony/flex": ">=1.3.1",
"symfony/form": ">=5.4.0",
"symfony/twig-bundle": ">=5.4.0",
"artgris/filemanager-bundle": "^2.2.0",
"artgris/filemanager-bundle": "^2.3.0",
"gregwar/image": "2.*",
"arkounay/ux-collection": "^2.0.0"
},
Expand Down

0 comments on commit 22d02be

Please sign in to comment.