You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

  1. <?php
  2. namespace App\Utilities\Avatar;
  3. use Spatie\MediaLibrary\MediaCollections\Models\Media;
  4. use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;
  5. class DefaultPathGenerator implements PathGenerator
  6. {
  7. /*
  8. * Get a unique base path for the given media.
  9. */
  10. protected function getBasePath(Media $media): string
  11. {
  12. return $media->model->getTable()."/";
  13. }
  14. /*
  15. * Get the path for the given media, relative to the root storage path.
  16. */
  17. public function getPath(Media $media): string
  18. {
  19. return $this->getBasePath($media);
  20. }
  21. /*
  22. * Get the path for conversions of the given media, relative to the root storage path.
  23. */
  24. public function getPathForConversions(Media $media): string
  25. {
  26. return $this->getBasePath($media);
  27. }
  28. /*
  29. * Get the path for responsive images of the given media, relative to the root storage path.
  30. */
  31. public function getPathForResponsiveImages(Media $media): string
  32. {
  33. return $this->getBasePath($media).'/responsive-images/';
  34. }
  35. }