如何显示图像数组中的单个图像

问题描述 投票:0回答:1

这是我获取所有图像的代码

@foreach (explode('|', $product->images) as $image) <img style="width:100%" src="/storage/image/{{$image}}"> @endforeach

只有我想显示该数组中的第一张图像我该怎么做

laravel laravel-5
1个回答
0
投票
@if (!empty($product->images))
    @php
        $images = explode('|', $product->images);
    @endphp
    @if (count($images) > 0)
        <img style="width:100%" src="/storage/image/{{$images[0]}}">
    @endif
@endif
© www.soinside.com 2019 - 2024. All rights reserved.