【发布时间】:2020-06-25 06:18:34
【问题描述】:
@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
如果图像可用,我想检查给定的 URL 是否有图像,那么@if 条件应该有效。但它不起作用
【问题讨论】:
-
这能回答你的问题吗? How to check if a file exists from a url
-
是的,但在我想在刀片中使用的情况下它不起作用
标签: laravel laravel-5 laravel-4