http://image.intervention.io/

composer require intervention/image

komutunu terminalden çalıştırarak eklentiyi yüklüyoruz.

config/app.php dosyasını açıp,

$providers dizisine:

Intervention\Image\ImageServiceProvider::class

$aliases dizisine:

‘Image’ => Intervention\Image\Facades\Image::class

ekliyoruz.

php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"

komutu ile kurulumu tamamlıyoruz.

Header dosyası olarak:

use Illuminate\Support\Facades\Input;
use Image;

ekliyoruz.

Örnek bir resim yükleme kodu:

 if($request->hasFile('image')){
                $image_tmp=Input::file('image');
                if($image_tmp->isValid()){
                    // Image Resize
                    if($image_tmp->isValid()){
                        $extension = $image_tmp->getClientOriginalExtension();
                        $filename = rand(111,99999).'.'.$extension;
                        //$fileName = $request->image->getClientOriginalName();
                        $large_image_path = 'images/backend_images/products/large/'.$filename;
                        $medium_image_path = 'images/backend_images/products/medium/'.$filename;
                        $small_image_path = 'images/backend_images/products/small/'.$filename;
                        // Resize Images
                        Image::make($image_tmp)->save($large_image_path);
                        Image::make($image_tmp)->resize(600,600)->save($medium_image_path);
                        Image::make($image_tmp)->resize(300,300)->save($small_image_path);
                        // Store image name in products table
                        $product->image = $filename;
                    }
                }
                
            }

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir