Reputation: 95
@if (file_exists(env('BASE_URL_MASTER').$p->main_image))
<img class="primary-img" src="{{env('BASE_URL_MASTER').$p->main_image}}" alt="single-product" height="200px" width="400px">
@else
<img class="primary-img" src="{{asset($p->main_image?$p->main_image:'')}}" alt="single-product" height="200px" width="400px">
endif
I want to check whether given URL has Image if image is available then @if
condition should work. but its not working
Upvotes: 2
Views: 2361
Reputation: 23
Using file_get_content()
instead.
Example:
$file = file_get_content('url_to_file or path_to_file');
if (strlen($file) > 0) 'file exist...'
Upvotes: 1