I'm having a problem with the getimagesize function, it freezes the server.
@foreach($categories as $category)
<span>{{$category->thumb}}</span>
<div class="box-categoria">
<a href="{{$category->generateCategoryUrl()}}">
@if(isset($category->thumb)&&$category->thumb != ""&&getimagesize($category->thumb))
<img src="{{$category->thumb}}" width="150"/>
@else
<img src="{{asset('assets/images/no-thumb.jpg')}}" width="150"/>
@endif
<div class="overlay"></div>
</a>
</div>
@endforeach
This works normally in another computers, it works even in the production server.
This project uses the Laravel framework, artisan server and the url of the image is like this:
Thanks
It's very strange to put this check (getimagesize
) in a blade view. It's back-end logic, and very bad for the performance to check this on the fly. A better way is to put this logic simplified like below in your blade view without the if-else condition.
<img src="{{$category->thumb}}" width="150" onerror="this.src='/assets/images/no-thumb.jpg';"/>
So if the thumb doesn't exist, the image no-thumb
will be loaded.