diff --git a/app/Controllers/HeaderImageController.php b/app/Controllers/HeaderImageController.php index 613edbe8f..7c87ee819 100644 --- a/app/Controllers/HeaderImageController.php +++ b/app/Controllers/HeaderImageController.php @@ -88,6 +88,10 @@ public function store(Request $request) $header_image = new HeaderImage($request->all()); $header_image->author()->associate($request->user()); + if($request->hasFile($this->form_field_name)){ + $header_image->type = explode('/',request()->{$this->form_field_name}->getMimeType())[0]; + } + $this->uploadImage($header_image); if ($header_image->save()) { diff --git a/app/Controllers/Trait/UploadsImage.php b/app/Controllers/Trait/UploadsImage.php index fb42af046..8f0a9f71d 100644 --- a/app/Controllers/Trait/UploadsImage.php +++ b/app/Controllers/Trait/UploadsImage.php @@ -24,7 +24,7 @@ public function uploadImage($model): bool { File::ensureDirectoryExists($model->getImageDirectory()); $img = request()->{$this->form_field_name}->store($this->getStrippedDirectoryPath($model)); $model->attachImage($img); - if (extension_loaded('gd')) { + if (extension_loaded('gd') && starts_with(request()->{$this->form_field_name}->getMimeType(), 'image/')) { File::ensureDirectoryExists($model->getImageDirectory() . '/thumbs'); \Intervention\Image\ImageManagerStatic::make(storage_path($img))->fit(300, 200)->save($model->getThumbnailDirectory(). DIRECTORY_SEPARATOR . $model->image); } diff --git a/app/Model/HeaderImage.php b/app/Model/HeaderImage.php index 18a86ac5c..2e7fd7d5e 100644 --- a/app/Model/HeaderImage.php +++ b/app/Model/HeaderImage.php @@ -19,7 +19,7 @@ class HeaderImage extends Model { * @var array */ protected $fillable = [ - 'title', 'link' ,'description', 'image', 'active', + 'title', 'type' ,'link' ,'description', 'image', 'active', ]; } diff --git a/app/View/media/header_images.blade.php b/app/View/media/header_images.blade.php index 37d8beeb4..fc3d43e46 100644 --- a/app/View/media/header_images.blade.php +++ b/app/View/media/header_images.blade.php @@ -37,10 +37,19 @@ + + @if($each->type === 'video') + + @else + @endif +