Hi, I’m having an issue displaying a cover image. I had it working once but have obviously changed something and I can’t see whats wrong with the set up.
Any pointers appreciated, here’s the blueprints and template code:
You don’t need a template, that’s true, but before you were searching for the cover via a cover template: $cover = $page->images()->findBy("template", "cover").
You’re not doing that anymore, that’s why your new code works.
You could rework your initial code to the following:
Excellent, thanks that works and I would say targeting the file field is a more focused approach. But I guess each approach has its merits and depends on how you want to use the panel.
If you have a field cover like you do in your blueprint, it makes sense to fetch the selected image from that field.
However, it is still strange that your first code snippet didn’t fetch the image because it should have (unless the image didn’t have the template assigned for some reason).