$file
The $file object provides a set of methods that can be used when dealing with a single image or other media file, like getting the URL or resizing an image. It also handles file meta data.
- 
    
            new File()
- 
    
            $image->base64()
- 
    
            $file->blueprint()
- 
    
            $file->blueprints()
- 
    
            $file->blur()
- 
    
            $file->bw()
- 
    
            $file->changeName()
- 
    
            $file->changeSort()
- 
    
            $file->clone()
- 
    
            $file->content()
- 
    
            $file->contentFiles()
- 
    
            $file->copy()
- 
    
            File::create()
- 
    
            $file->crop()
- 
    
            $image->dataUri()
- 
    
            $file->decrement()
- 
    
            $file->delete()
- 
    
            $image->dimensions()
- 
    
            $image->download()
- 
    
            $file->errors()
- 
    
            $image->exif()
- 
    
            $file->exists()
- 
    
            $file->extension()
- 
    
            $file->filename()
- 
    
            $file->files()
- 
    
            $file->grayscale()
- 
    
            $file->greyscale()
- 
    
            $file->hardcopy()
- 
    
            $file->hasNext()
- 
    
            $file->hasPrev()
- 
    
            $image->hash()
- 
    
            $image->header()
- 
    
            $image->height()
- 
    
            $file->html()
- 
    
            $file->id()
- 
    
            $image->imagesize()
- 
    
            $file->increment()
- 
    
            $file->indexOf()
- 
    
            $file->is()
- 
    
            $file->isFirst()
- 
    
            $image->isLandscape()
- 
    
            $file->isLast()
- 
    
            $file->isLocked()
- 
    
            $file->isNth()
- 
    
            $image->isPortrait()
- 
    
            $file->isReadable()
- 
    
            $file->isResizable()
- 
    
            $image->isSquare()
- 
    
            $file->isValid()
- 
    
            $file->isViewable()
- 
    
            $image->isWritable()
- 
    
            $file->kirby()
- 
    
            $file->lock()
- 
    
            $image->match()
- 
    
            $image->mime()
- 
    
            $file->modified()
- 
    
            $image->move()
- 
    
            $image->name()
- 
    
            $file->next()
- 
    
            $file->nextAll()
- 
    
            $image->niceSize()
- 
    
            $image->orientation()
- 
    
            $file->page()
- 
    
            $file->panelOptions()
- 
    
            $file->panelPickerData()
- 
    
            $file->parent()
- 
    
            $file->parents()
- 
    
            $file->permissions()
- 
    
            $file->prev()
- 
    
            $file->prevAll()
- 
    
            $file->publish()
- 
    
            $file->quality()
- 
    
            $image->ratio()
- 
    
            $image->read()
- 
    
            $image->realpath()
- 
    
            $image->rename()
- 
    
            $file->replace()
- 
    
            $file->resize()
- 
    
            $file->root()
- 
    
            $file->siblings()
- 
    
            $file->site()
- 
    
            $image->size()
- 
    
            $file->srcset()
- 
    
            $file->template()
- 
    
            $file->templateSiblings()
- 
    
            $file->thumb()
- 
    
            $file->toArray()
- 
    
            $image->toJson()
- 
    
            $file->toString()
- 
    
            $file->translation()
- 
    
            $file->translations()
- 
    
            $file->type()
- 
    
            $file->unpublish()
- 
    
            $file->update()
- 
    
            $file->url()
- 
    
            $image->validateContents()
- 
    
            $image->width()
- 
    
            $image->write()
You can extend this set of methods with custom file methods.
How to get a $file object
You can get a $file object to use with these methods by fetching it from the $site, a $page or a $user object.
Site file
<?php if ($file = $site->files()->first()): ?>
<img src="<?= $file->url() ?>" alt="">
<?php endif ?>Page file
<?php if ($file = $page->files()->first()): ?>
<img src="<?= $file->url() ?>" alt="">
<?php endif ?>User file
<?php if ($file = $user->files()->first()): ?>
<img src="<?= $file->url() ?>" alt="">
<?php endif ?>Note how we use an if statement here to check if we have a file object before we call the url() method to prevent errors in case the page doesn't have any files. Never forget to do this in your own code.
Examples
Resizing a file
<?php if ($image = $page->image('myimage.jpg')): ?>
<img src="<?= $image->resize(300)->url() ?>" alt="">
<?php endif ?>