If/else query for single image or multiple images

I am looking for the procedure for an if/else query for the following task:

If an article page has 1 image uploaded, it should be displayed in the header.
If more than one image is uploaded, a slider should be displayed in the header instead.

With an if/else submission I have to include two different HTML blocks.
This is not a problem, I already have these blocks.

So far, I’ve gone the manual route, but it’s error-prone and requires intervention when the image count changes:

<?php if($page->singleimageorslider() == "true"): ?>
<div> …

My question: How do I create a count() query in the template for the number of uploaded images?

If it’s just about all/any image uploaded to the page:

if ($page->images()->count() > 1):
1 Like

Thank you very much for the quick support.
I added a query in the template with 3 options where the user can choose: show profile picture only, show photo gallery, show no picture. It works perfectly, thanks to your help.