texnixe
21
If you use echo, you have to use a full php tag, not just <?
<?php echo $image->url() ?>
Or use the short echo tag <?=
<img src="<?= $image->url() ?>" alt="" />
(It is possible to use the short opening tag <?
if you enable it on your server, but that is highly discouraged.)
Thanks, It works. I am grateful
is it possible to have 2 image fields in a structure?
mine is displaying one image in the two fields.
here is my code:
<?php foreach ($page->innovations()->toStructure() as $innovation): ?>
<div class="col-md-6">
<div class="solution-img">
<?php if ($image = $innovation->image()->toFile()): ?>
<div class="img-holder">
< img src=" <?= $image->url() ?> " alt="MyStaff" >
</div>
<?php endif ?>
</div>
<div class="solution-details">
<?php if ($detailslogo = $innovation->image()->toFile()): ?>
< img src="<?= $detailslogo->url() ?>" alt="MyStaff">
<?php endif ?>
<p class="solution-desc"><?= $innovation->details() ?></p>
<?php endforeach ?>
Please post your blueprint, you are using the same image ($innovation->image()) for both instances, even if you store it in different variables.
texnixe
28
I can only repeat what was already asked above:
Please post your blueprint with the structure field.
Innovations:
columns:
right:
width: 2/3
sections:
fields:
Innovations:
label: Innovations
type: structure
sectionField: section
fields:
image:
label: Innovation Image
type: files
detailslogo:
label: Details Logo
type: files
details:
label: Innovation Text
type: textarea
should be:
<?php if ($detailslogo = $innovation->detailslogo()->toFile()): ?>
texnixe
31
To get the file store in the image field:
<?php if ($image = $innovation->content()->get('image')->toFile()): ?>
When using field names reserved by Kirby’s native methods, you have to go via the content
object or rename your fields.