diff --git a/src/Kunstmaan/MediaBundle/DependencyInjection/KunstmaanMediaExtension.php b/src/Kunstmaan/MediaBundle/DependencyInjection/KunstmaanMediaExtension.php index 37fab40fd8..80bbcea426 100644 --- a/src/Kunstmaan/MediaBundle/DependencyInjection/KunstmaanMediaExtension.php +++ b/src/Kunstmaan/MediaBundle/DependencyInjection/KunstmaanMediaExtension.php @@ -43,7 +43,7 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('kunstmaan_media.enable_pdf_preview', $config['enable_pdf_preview']); $container->setParameter('kunstmaan_media.blacklisted_extensions', $config['blacklisted_extensions']); $container->setParameter('kunstmaan_media.web_root', $config['web_root']); - $container->setParameter('kunstmaan_media.full_media_path', $config['web_root'] . '%kunstmaan_media.media_path%'); + $container->setParameter('kunstmaan_media.full_media_path', $config['web_root'] . '%kunstmaan_media.media_path%'); // Not used, deprecate? $loader->load('services.yml'); $loader->load('handlers.yml'); @@ -74,12 +74,12 @@ public function load(array $configs, ContainerBuilder $container) public function prepend(ContainerBuilder $container) { - if (!$container->hasParameter('kunstmaan_media.upload_dir')) { + if (!$container->hasParameter('kunstmaan_media.upload_dir')) { // Not used, deprecate? $container->setParameter('kunstmaan_media.upload_dir', '/uploads/media/'); } $twigConfig = []; - $twigConfig['globals']['upload_dir'] = $container->getParameter('kunstmaan_media.upload_dir'); + $twigConfig['globals']['upload_dir'] = $container->getParameter('kunstmaan_media.upload_dir'); // Not used, deprecate? $twigConfig['globals']['mediabundleisactive'] = true; $twigConfig['globals']['mediamanager'] = '@kunstmaan_media.media_manager'; $container->prependExtensionConfig('twig', $twigConfig); diff --git a/src/Kunstmaan/MediaBundle/Helper/File/FileHandler.php b/src/Kunstmaan/MediaBundle/Helper/File/FileHandler.php index e63bb831b2..17100bd553 100644 --- a/src/Kunstmaan/MediaBundle/Helper/File/FileHandler.php +++ b/src/Kunstmaan/MediaBundle/Helper/File/FileHandler.php @@ -225,7 +225,7 @@ public function prepareMedia(Media $media) $media->setContentType($contentType); $media->setFileSize(filesize($media->getContent())); - $media->setUrl($this->mediaPath.$this->getFilePath($media)); + $media->setUrl($this->getFilePath($media)); $media->setLocation('local'); } @@ -355,7 +355,8 @@ private function getFilePath(Media $media) } return sprintf( - '%s/%s', + '%s%s/%s', + $this->mediaPath, $media->getUuid(), $filename ); @@ -368,7 +369,9 @@ private function getFilePath(Media $media) */ private function getFileFolderPath(Media $media) { - return substr($this->getFilePath($media), 0, strrpos($this->getFilePath($media), $media->getOriginalFilename())); + $filePath = $this->getFilePath($media); + + return substr($filePath, 0, strrpos($filePath, $media->getOriginalFilename())); } private function guessMimeType($pathName) diff --git a/src/Kunstmaan/MediaBundle/Resources/config/services.yml b/src/Kunstmaan/MediaBundle/Resources/config/services.yml index 4dade63c72..8cfbc47473 100644 --- a/src/Kunstmaan/MediaBundle/Resources/config/services.yml +++ b/src/Kunstmaan/MediaBundle/Resources/config/services.yml @@ -114,7 +114,7 @@ services: kunstmaan_media.filesystem_adapter: class: Gaufrette\Adapter\Local arguments: - - '%kunstmaan_media.full_media_path%' + - '%kunstmaan_media.web_root%' - true kunstmaan_media.filesystem: