$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()
-
$image->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()
-
$image->dataUri()
-
$file->decrement()
-
$file->delete()
-
$image->dimensions()
-
$image->download()
-
$file->dragText()
-
$file->dragTextFromCallback()
-
$file->dragTextType()
-
$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()
-
$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()
-
$file->mediaHash()
-
$file->mediaRoot()
-
$file->mediaToken()
-
$file->mediaUrl()
-
$image->mime()
-
$file->modified()
-
$image->move()
-
$image->name()
-
$file->next()
-
$file->nextAll()
-
$image->niceSize()
-
$image->orientation()
-
$file->page()
-
$file->panelIcon()
-
$file->panelImage()
-
$file->panelOptions()
-
$file->panelPath()
-
$file->panelPickerData()
-
$file->panelUrl()
-
$file->parent()
-
$file->parentId()
-
$file->parents()
-
$file->permissions()
-
$file->prev()
-
$file->prevAll()
-
$file->publish()
-
$file->quality()
-
$file->query()
-
$image->ratio()
-
$image->read()
-
$file->readContent()
-
$image->realpath()
-
$image->rename()
-
$file->replace()
-
$file->resize()
-
$file->root()
-
$file->save()
-
$file->setSite()
-
$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()
-
$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
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.