Using Channel Images With Coilpack
Requirments
- Coilpack working and already installed
- Channel Images Version 7.6.0
All of the below examples can also be seen in the templates example folder when getting the addon.
Twig
The main Images Tag Example
{% for theimage in exp.channel_images.images({entry_id: '36'}) %}
<img src={{ attribute(theimage, 'image:url') }}> </img>
{{ attribute(theimage, 'image:url') }}
{{ theimage['image:url']}}
{% endfor %}
The Fieldtype Example This following example assumes that:
- You have a channel images field named "channel_images"
- That "channel_images" field is in a channel called "my_channel"
The ".files" part will be consistent for all channel images fields. **(Note, the only time "image:" part may differ if you are using prefixes in nested tags)
{% for entry in exp.channel.entries({channel: "my_channel",}) %}
<h1> {{ entry.title }} </h1>
<br>
{% for image in entry.channel_images.files %}
<img src={{ attribute(image, 'image:url') }}> </img>
<p>{{attribute(image, 'image:url')}} </p>
{% endfor %}
<br>
{% endfor %}
Blade
The main Images Tag Example for Blade
@foreach($exp->channel_images->images(["entry_id" => "36"]) as $theimage)
{{ $theimage['image:url'] }}
@endforeach
The Fieldtype Example
@foreach($exp->channel->entries(["channel" => "channel_images"]) as $entry)
{{ $entry->title }}
@foreach($entry->channel_images->files as $file)
{{$file["image:url"]}}
@endforeach
@endforeach