mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-12 18:01:06 +03:30
fix media
This commit is contained in:
+14
-8
@@ -38,19 +38,25 @@ class Item extends Model implements HasMedia
|
||||
return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" , "approved" )->whereNull( "to_date" );
|
||||
}
|
||||
|
||||
public function registerMediaCollections()
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection( 'main_images' )
|
||||
->useFallbackUrl( '/images/default_pastry.jpg' )
|
||||
->useFallbackPath( public_path( '/images/default_pastry.jpg' ) );
|
||||
$this->addMediaCollection( 'main_image' )
|
||||
->useFallbackUrl( config( 'media-library.wm-cdn' ) . '/images/placeholder/blog-placeholder.jpg' )
|
||||
->useFallbackPath( public_path( '/images/placeholder/blog-placeholder.jpg' ) )
|
||||
->singleFile();
|
||||
}
|
||||
|
||||
public function registerMediaConversions( Media $media = null ): void
|
||||
public function registerMediaConversions( Media $media = null )
|
||||
{
|
||||
$crop = $media->getCustomProperty( 'crop' );
|
||||
$conversion = $this->addMediaConversion( 'thumbnail' );
|
||||
$conversion = ! $crop ? $conversion : $conversion->manualCrop( $crop[ 'width' ] , $crop[ 'height' ] , $crop[ 'left' ] , $crop[ 'top' ] );
|
||||
$conversion->nonQueued()
|
||||
->performOnCollections( 'main_image' );
|
||||
|
||||
$this->addMediaConversion( 'thumbnail' )
|
||||
->width( 480 )
|
||||
->height( 640 )
|
||||
->width( 400 )
|
||||
->nonQueued()
|
||||
->performOnCollections( 'main_images' );
|
||||
->performOnCollections( 'images' );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user