$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.
-
$file->asset()
-
$file->base64()
-
$file->blueprint()
-
$file->blueprints()
-
$file->blur()
-
$file->bw()
-
$file->changeName()
-
$file->changeSort()
-
$file->clone()
-
$file->content()
-
$file->contentFiles()
-
$file->copy()
-
$file->crop()
-
$file->dataUri()
-
$file->decrement()
-
$file->delete()
-
$file->download()
-
$file->errors()
-
$file->exists()
-
$file->extension()
-
$file->filename()
-
$file->files()
-
$file->grayscale()
-
$file->greyscale()
-
$file->hardcopy()
-
$file->hash()
-
$file->hasNext()
-
$file->hasPrev()
-
$file->header()
-
$file->html()
-
$file->id()
-
$file->increment()
-
$file->indexOf()
-
$file->is()
-
$file->isFirst()
-
$file->isLast()
-
$file->isLocked()
-
$file->isNth()
-
$file->isReadable()
-
$file->isResizable()
-
$file->isValid()
-
$file->isViewable()
-
$file->isWritable()
-
$file->kirby()
-
$file->lock()
-
$file->match()
-
$file->mime()
-
$file->model()
-
$file->modified()
-
$file->move()
-
$file->name()
-
$file->next()
-
$file->nextAll()
-
$file->niceSize()
-
$file->page()
-
$file->panel()
-
$file->parent()
-
$file->parents()
-
$file->permalink()
-
$file->permissions()
-
$file->prev()
-
$file->prevAll()
-
$file->previewUrl()
-
$file->publish()
-
$file->quality()
-
$file->read()
-
$file->realpath()
-
$file->rename()
-
$file->replace()
-
$file->resize()
-
$file->root()
-
$file->sanitizeContents()
-
$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->uuid()
-
$file->validateContents()
-
$file->write()
-
$image->dimensions()
-
$image->exif()
-
$image->height()
-
$image->imagesize()
-
$image->isLandscape()
-
$image->isPortrait()
-
$image->isSquare()
-
$image->orientation()
-
$image->ratio()
-
$image->width()
-
File::create()
-
new File()
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
Page file
User file
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.