From 4e19138724f14c6e4d11d8924861fc4ea7367029 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 24 Mar 2022 20:56:43 +0100 Subject: [PATCH] Fixed: Slug filename before saving it --- classes/SocialService.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/SocialService.php b/classes/SocialService.php index ef36f76..f15e5a8 100644 --- a/classes/SocialService.php +++ b/classes/SocialService.php @@ -10,8 +10,8 @@ use Zoomyboy\Social\Exceptions\SocialException; use Zoomyboy\Social\Models\Page; use Zoomyboy\Social\Models\Setting; -abstract class SocialService { - +abstract class SocialService +{ protected $page; protected $media; @@ -50,7 +50,8 @@ abstract class SocialService { return Page::where('type', $this->getType())->get(); } - public function clear() { + public function clear() + { $this->page->delete(); } @@ -73,6 +74,8 @@ abstract class SocialService { throw new SocialException('No real filename for storage given in "'.$source.'"'); } + $filename = str_slug(pathinfo($filename, PATHINFO_FILENAME)).'.'.pathinfo($filename, PATHINFO_EXTENSION); + $file = $this->page->mediaPath.$filename; if (!$this->media->exists($file)) { @@ -101,5 +104,4 @@ abstract class SocialService { $this->cleanOutdated(); } - }