mirror of
https://github.com/openclassify/openclassify.git
synced 2026-04-14 11:12:09 -05:00
35 lines
868 B
PHP
35 lines
868 B
PHP
<?php
|
|
|
|
namespace Modules\Site\App\Support;
|
|
|
|
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
|
use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;
|
|
|
|
class ScopedMediaPathGenerator implements PathGenerator
|
|
{
|
|
public function getPath(Media $media): string
|
|
{
|
|
return $this->basePath($media).'/';
|
|
}
|
|
|
|
public function getPathForConversions(Media $media): string
|
|
{
|
|
return $this->basePath($media).'/conversions/';
|
|
}
|
|
|
|
public function getPathForResponsiveImages(Media $media): string
|
|
{
|
|
return $this->basePath($media).'/responsive-images/';
|
|
}
|
|
|
|
private function basePath(Media $media): string
|
|
{
|
|
$scope = trim((string) $media->getCustomProperty('path_scope', ''));
|
|
$key = (string) $media->getKey();
|
|
|
|
return $scope !== ''
|
|
? $scope.'/'.$key
|
|
: $key;
|
|
}
|
|
}
|