add methods to get icon on article natures
This commit is contained in:
31
app/Repositories/Core/MediaPathGenerator.php
Normal file
31
app/Repositories/Core/MediaPathGenerator.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;
|
||||
|
||||
class MediaPathGenerator implements PathGenerator
|
||||
{
|
||||
public function getPath(Media $media): string
|
||||
{
|
||||
return $this->getBasePath($media).'/';
|
||||
}
|
||||
|
||||
public function getPathForConversions(Media $media): string
|
||||
{
|
||||
return $this->getBasePath($media).'/conversions/';
|
||||
}
|
||||
|
||||
public function getPathForResponsiveImages(Media $media): string
|
||||
{
|
||||
return $this->getBasePath($media).'/responsive-images/';
|
||||
}
|
||||
|
||||
protected function getBasePath(Media $media): string
|
||||
{
|
||||
$model = basename(str_replace('\\', '/', $media->model_type));
|
||||
|
||||
return basename($model).'/images/'.$media->getKey();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user