61 return new static(
false,
false,
$path,
$mime );
86 ': not enough parameters, must specify title and repo, or a full path' );
92 $this->name = basename(
$path );
106 $this->pageDims = [];
119 if ( !isset( $this->pageDims[$page] ) ) {
123 if ( $this->
getHandler()->isMultiPage( $this ) ) {
124 $this->pageDims[$page] = $this->handler->getPageDimensions( $this, $page );
128 'width' => $info[
'width'],
129 'height' => $info[
'height']
134 return $this->pageDims[$page];
144 return $dim[
'width'] ?? 0;
154 return $dim[
'height'] ?? 0;
161 if ( !isset( $this->mime ) ) {
162 $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
174 return $info[
'bits'] ?? 0;
182 return $info[
'metadata'] ?
serialize( $info[
'metadata'] ) :
false;
187 return $info[
'metadata'];
191 if ( $this->sizeAndMetadata ===
null ) {
192 if ( !$this->getHandler() ) {
193 $this->sizeAndMetadata = [
'width' => 0,
'height' => 0,
'metadata' => [] ];
195 $this->sizeAndMetadata = $this->getHandler()->getSizeAndMetadataWithFallback(
196 $this, $this->getLocalRefPath() );
200 return $this->sizeAndMetadata;
208 return $this->repo->getZoneUrl(
'public' ) .
'/' .
209 $this->repo->getHashPath( $this->name ) . rawurlencode( $this->name );
219 $this->assertRepoDefined();
221 return $this->repo->getFileSize( $this->path );
233 $this->fsFile = $fsFile;
Class representing a non-directory file on the file system.
getRootDirectory()
Get the public zone root storage directory of the repository.
getNameFromTitle( $title)
Get the name of a file from its title.
getHashPath( $name)
Get a relative path including trailing slash, e.g.
Implements some public methods and some protected utility functions which are required by multiple ch...
static normalizeTitle( $title, $exception=false)
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
getLocalRefPath()
Get an FS copy or original of this file and return the path.
string $name
The name of a file from its title object.
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
getHandler()
Get a MediaHandler instance for this file.
Represents a title within MediaWiki.
A file object referring to either a standalone local file, or a file in a local repository with no da...
array null $sizeAndMetadata
setLocalReference(FSFile $fsFile)
Optimize getLocalRefPath() by using an existing local reference.
array[] bool[] $pageDims
Dimension data.
__construct( $title=false, $repo=false, $path=false, $mime=false)
Create an UnregisteredLocalFile based on a path or a (title,repo) pair.
getMetadataArray()
Get the unserialized handler-specific metadata STUB.
static newFromPath( $path, $mime)
cachePageDimensions( $page=1)
static newFromTitle( $title, $repo)