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 );
119 if ( !isset( $this->dims[$page] ) ) {
123 $this->dims[$page] = $this->handler->getPageDimensions( $this, $page );
126 return $this->dims[$page];
136 return $dim[
'width'] ?? 0;
146 return $dim[
'height'] ?? 0;
153 if ( !isset( $this->mime ) ) {
154 $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
170 return $this->handler->getImageSize( $this, $this->
getLocalRefPath() );
179 if ( !$gis || !isset( $gis[
'bits'] ) ) {
189 if ( !isset( $this->metadata ) ) {
191 $this->metadata =
false;
193 $this->metadata = $this->handler->getMetadata( $this, $this->
getLocalRefPath() );
205 return $this->repo->getZoneUrl(
'public' ) .
'/' .
206 $this->repo->getHashPath( $this->name ) . rawurlencode( $this->name );
218 return $this->repo->getFileSize( $this->path );
Class representing a non-directory file on the file system.
getRootDirectory()
Get the public zone root storage directory of the repository.
getHashPath( $name)
Get a relative path including trailing slash, e.g.
getNameFromTitle(Title $title)
Get the name of a file from its title object.
Implements some public methods and some protected utility functions which are required by multiple ch...
FSFile bool $fsFile
False if undefined.
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...
setLocalReference(FSFile $fsFile)
Optimize getLocalRefPath() by using an existing local reference.
array[] bool[] $dims
Dimension data.
__construct( $title=false, $repo=false, $path=false, $mime=false)
Create an UnregisteredLocalFile based on a path or a (title,repo) pair.
static newFromPath( $path, $mime)
cachePageDimensions( $page=1)
static newFromTitle( $title, $repo)
bool string $metadata
Handler-specific metadata which will be saved in the img_metadata field.