$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()
 - 
    
      
      
$file->apiUrl()
 - 
    
      
      
$file->asset()
 - 
    
      
      
$file->base64()
 - 
    
      
      
$file->blueprint()
 - 
    
      
      
$file->blueprints()
 - 
    
      
      
$file->blur()
 - 
    
      
      
$file->bw()
 - 
    
      
      
$file->callMethod()
 - 
    
      
      
$file->changeName()
 - 
    
      
      
$file->changeSort()
 - 
    
      
      
$file->clone()
 - 
    
      
      
$file->content()
 - 
    
      
      
$file->contentFile()
 - 
    
      
      
$file->contentFileData()
 - 
    
      
      
$file->contentFileDirectory()
 - 
    
      
      
$file->contentFileExtension()
 - 
    
      
      
$file->contentFileName()
 - 
    
      
      
$file->contentFiles()
 - 
    
      
      
$file->copy()
 - 
    
      
      
File::create()
 - 
    
      
      
$file->crop()
 - 
    
      
      
$file->dataUri()
 - 
    
      
      
$file->decrement()
 - 
    
      
      
$file->delete()
 - 
    
      
      
$image->dimensions()
 - 
    
      
      
$file->download()
 - 
    
      
      
$file->dragText()
 - 
    
      
      
$file->errors()
 - 
    
      
      
$image->exif()
 - 
    
      
      
$file->exists()
 - 
    
      
      
$file->extension()
 - 
    
      
      
File::factory()
 - 
    
      
      
$file->filename()
 - 
    
      
      
$file->files()
 - 
    
      
      
$file->grayscale()
 - 
    
      
      
$file->greyscale()
 - 
    
      
      
$file->hardcopy()
 - 
    
      
      
$file->hasMethod()
 - 
    
      
      
$file->hasNext()
 - 
    
      
      
$file->hasPrev()
 - 
    
      
      
$file->hash()
 - 
    
      
      
$file->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()
 - 
    
      
      
$file->isWritable()
 - 
    
      
      
$file->kirby()
 - 
    
      
      
$file->lock()
 - 
    
      
      
$file->match()
 - 
    
      
      
$file->mediaHash()
 - 
    
      
      
$file->mediaRoot()
 - 
    
      
      
$file->mediaToken()
 - 
    
      
      
$file->mediaUrl()
 - 
    
      
      
$file->mime()
 - 
    
      
      
$file->modified()
 - 
    
      
      
$file->move()
 - 
    
      
      
$file->name()
 - 
    
      
      
$file->next()
 - 
    
      
      
$file->nextAll()
 - 
    
      
      
$file->niceSize()
 - 
    
      
      
$image->orientation()
 - 
    
      
      
$file->page()
 - 
    
      
      
$file->panel()
 - 
    
      
      
$file->panelOptions()
 - 
    
      
      
$file->panelPath()
 - 
    
      
      
$file->panelPickerData()
 - 
    
      
      
$file->panelUrl()
 - 
    
      
      
$file->parent()
 - 
    
      
      
$file->parentId()
 - 
    
      
      
$file->parents()
 - 
    
      
      
$file->permissions()
 - 
    
      
      
$file->prev()
 - 
    
      
      
$file->prevAll()
 - 
    
      
      
$file->previewUrl()
 - 
    
      
      
$file->publish()
 - 
    
      
      
$file->quality()
 - 
    
      
      
$file->query()
 - 
    
      
      
$image->ratio()
 - 
    
      
      
$file->read()
 - 
    
      
      
$file->readContent()
 - 
    
      
      
$file->realpath()
 - 
    
      
      
$file->rename()
 - 
    
      
      
$file->replace()
 - 
    
      
      
$file->resize()
 - 
    
      
      
$file->root()
 - 
    
      
      
$file->sanitizeContents()
 - 
    
      
      
$file->save()
 - 
    
      
      
$file->setSite()
 - 
    
      
      
$file->sha1()
 - 
    
      
      
$file->siblings()
 - 
    
      
      
$file->site()
 - 
    
      
      
$file->size()
 - 
    
      
      
$file->srcset()
 - 
    
      
      
$file->template()
 - 
    
      
      
$file->templateSiblings()
 - 
    
      
      
$file->thumb()
 - 
    
      
      
$file->toArray()
 - 
    
      
      
$file->toJson()
 - 
    
      
      
$file->toSafeString()
 - 
    
      
      
$file->toString()
 - 
    
      
      
$file->translation()
 - 
    
      
      
$file->translations()
 - 
    
      
      
$file->type()
 - 
    
      
      
$file->unpublish()
 - 
    
      
      
$file->update()
 - 
    
      
      
$file->url()
 - 
    
      
      
$file->validateContents()
 - 
    
      
      
$image->width()
 - 
    
      
      
$file->write()
 - 
    
      
      
$file->writeContent()
 
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 ?>