$page->image($filename = false)

Returns a specific image $file object by filename. If no filename is given, the first available image will be returned.

  • $filename (string)
    Optional, a filename
  • return ($file)

Example

Fetching the first image

<?php if($image = $page->image()): ?>
<img src="<?php echo $image->url() ?>" alt="">
<?php endif ?>

Fetching a specific image

<?php if($image = $page->image('myimage.jpg')): ?>
<img src="<?php echo $image->url() ?>" alt="">
<?php endif ?>