Voyager: Multiple Image Option

Created on 29 Mar 2018  路  7Comments  路  Source: the-control-group/voyager

  • Laravel Version: 5.5.39
  • Voyager Version: 1.0
  • PHP Version:7.2.3
  • Database Driver & Version:

Description: I have chosen 'multiple images' in my 'gallery' title. I've already uploaded 5 images in admin dashboard. How to call all the images in my blade using @foreach .

Steps To Reproduce:

with code in my blade

@foreach($gallery` as $galleries)   
<img src="{{Voyager::image($galleries->gallery_images)}}" class="img-responsive img-thumbnail" />
@endforeach

It showed One broken Image

All 7 comments

I dont understand it.
@foreach($gallery as $galleries)
Shouldn't that be vice versa?
$galleries->gallery_images
Seems to be an array, so you would to json_decode it, foreach through it, and then use it in an <img> tag

"Multiple images" stores it's value as a json-encoded array of paths. You need to json_decode the value from the database, then loop over the result, then display it with Voyager::image

@monazthapa you need to do next:
```
$images = json_decode($dataTypeContent->images);
if($images != null)
@foreach($images as $image)

@endforeach
@endif
````

This is now in our docs.

This should do it
@foreach ($galleries as $gallery)
@foreach (json_decode($gallery->gallery_images) as $image)
<img src="{{ Voyager::image($image)}}">
@endforeach
@endforeach

Please don't necro issues like this that have been closed for ~9 months.

When json decode then files shows broken image. Can anyone explain

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TPRAsh picture TPRAsh  路  3Comments

MikadoInfo picture MikadoInfo  路  3Comments

TXRRNT picture TXRRNT  路  3Comments

duongsieu picture duongsieu  路  3Comments

rayqiri picture rayqiri  路  3Comments