hi,
i’m using lingonberry template and i want to add a feature to display a default image, if there is no cover image selected on a specific page template.
i just add the string of the imagefile location to the variable $image and i can’t use things like $image->resize(766, null, 85)->url()
as far as i understand, the problem is, that $image = $item->coverimage()->toFile() generates an object, that is not the same as a string of path to file.
so, i think i need to generate such an object of the “external” image, like it is done with the image of the field.
This happens because Assets don‘t have a meta .txt file where additional file field content can be stored. The same will happen with $image->caption().
I would try something like this …
<div class="featured-media">
<a href="<?= $item->url() ?>">
<?php if($image = $item->coverimage()->toFile()) : ?>
<img src="<?= $image->resize(766, null, 85)->url() ?>" rel="bookmark" title="<?= $item->title()->html() ?>"<?php e($image->alt()->isNotEmpty(), ' alt="' . $image->alt()->html() . '"') ?>>
<!-- ... and so on -->
<?php else: ?>
<!-- load image from assets and add alt and caption text on your own -->
<?php endif; ?>
</a>
</div>
the question is just a start of editing this snippet. i want to do many things with the image. for example overlaying a watermark. (already got a solution on this)