I have more than 8000 images in my laravel project and most of these images are in different type distentions. So what I trying to do is check and dimensions of images via getimagesize()
but when i use this function in laravel controller it dosen't output anything . Please refer the code that I have tried. When I dd()
the image url its working but when I pass the url to the function it just exceed the execution time and nothing happen. But if I pass a different url to the method (something almost hosted) It output the result I wants. I have gone through below question and Yes I feel that there is something with the path of the image. So could anyone please help me to solve this.
<?php
namespace App\Http\Controllers;
use App\Product;
use function asset ;
use Illuminate\Http\Request;
use ParagonIE\Sodium\File;
class testingController extends Controller
{
public function testing (){
//fetching all the products from the DB
$products = Product::all();
//looping the products and generating image path
foreach ($products as $product) {
//image path
$img = asset ( 'uploads/products_thumbnails').'/'.$product->thumbnail_file_name;
// dd($img); //this is working
//http://localhost:8000/products/1234568.jpg
$check = getimagesize ( $img);
dd($check); //this dosen't output anything
// if ( File::exists($img)){
// }
}
}
}
But if I trying something like below its working
$check = getimagesize ( 'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png');
dd($check);
array:6 [▼
0 => 272
1 => 92
2 => 3
3 => "width="272" height="92""
"bits" => 8
"mime" => "image/png"
]
Please note that I have almost gone through below questions.
Problem is with this function
$img = asset ( 'uploads/products_thumbnails').'/'.$product->thumbnail_file_name;
Try accessing your public folder without asset function.
$img = 'uploads/products_thumbnails/'.$product->thumbnail_file_name;