MediaWiki  master
File.php
Go to the documentation of this file.
1 <?php
8 use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
14 
37 // @phan-file-suppress PhanTypeMissingReturn false positives
66 abstract class File implements IDBAccessObject, MediaHandlerState {
67  use ProtectedHookAccessorTrait;
68 
69  // Bitfield values akin to the revision deletion constants
70  public const DELETED_FILE = 1;
71  public const DELETED_COMMENT = 2;
72  public const DELETED_USER = 4;
73  public const DELETED_RESTRICTED = 8;
74 
76  public const RENDER_NOW = 1;
81  public const RENDER_FORCE = 2;
82 
83  public const DELETE_SOURCE = 1;
84 
85  // Audience options for File::getDescription()
86  public const FOR_PUBLIC = 1;
87  public const FOR_THIS_USER = 2;
88  public const RAW = 3;
89 
90  // Options for File::thumbName()
91  public const THUMB_FULL_NAME = 1;
92 
113  public $repo;
114 
116  protected $title;
117 
119  protected $lastError;
120 
122  protected $redirected;
123 
125  protected $redirectedTitle;
126 
128  protected $fsFile;
129 
131  protected $handler;
132 
134  protected $url;
135 
137  protected $extension;
138 
140  protected $name;
141 
143  protected $path;
144 
146  protected $hashPath;
147 
151  protected $pageCount;
152 
154  protected $transformScript;
155 
157  protected $redirectTitle;
158 
160  protected $canRender;
161 
165  protected $isSafeFile;
166 
168  protected $repoClass = FileRepo::class;
169 
171  protected $tmpBucketedThumbCache = [];
172 
174  private $handlerState = [];
175 
187  public function __construct( $title, $repo ) {
188  // Some subclasses do not use $title, but set name/title some other way
189  if ( $title !== false ) {
190  $title = self::normalizeTitle( $title, 'exception' );
191  }
192  $this->title = $title;
193  $this->repo = $repo;
194  }
195 
205  public static function normalizeTitle( $title, $exception = false ) {
206  $ret = $title;
207 
208  if ( !$ret instanceof Title ) {
209  if ( $ret instanceof PageIdentity ) {
210  $ret = Title::castFromPageIdentity( $ret );
211  } elseif ( $ret instanceof LinkTarget ) {
212  $ret = Title::castFromLinkTarget( $ret );
213  }
214  }
215 
216  if ( $ret instanceof Title ) {
217  # Normalize NS_MEDIA -> NS_FILE
218  if ( $ret->getNamespace() === NS_MEDIA ) {
219  $ret = Title::makeTitleSafe( NS_FILE, $ret->getDBkey() );
220  # Sanity check the title namespace
221  } elseif ( $ret->getNamespace() !== NS_FILE ) {
222  $ret = null;
223  }
224  } else {
225  # Convert strings to Title objects
226  $ret = Title::makeTitleSafe( NS_FILE, (string)$ret );
227  }
228  if ( !$ret && $exception !== false ) {
229  throw new MWException( "`$title` is not a valid file title." );
230  }
231 
232  return $ret;
233  }
234 
235  public function __get( $name ) {
236  $function = [ $this, 'get' . ucfirst( $name ) ];
237  if ( !is_callable( $function ) ) {
238  return null;
239  } else {
240  $this->$name = $function();
241 
242  return $this->$name;
243  }
244  }
245 
254  public static function normalizeExtension( $extension ) {
255  $lower = strtolower( $extension );
256  $squish = [
257  'htm' => 'html',
258  'jpeg' => 'jpg',
259  'mpeg' => 'mpg',
260  'tiff' => 'tif',
261  'ogv' => 'ogg' ];
262  if ( isset( $squish[$lower] ) ) {
263  return $squish[$lower];
264  } elseif ( preg_match( '/^[0-9a-z]+$/', $lower ) ) {
265  return $lower;
266  } else {
267  return '';
268  }
269  }
270 
279  public static function checkExtensionCompatibility( File $old, $new ) {
280  $oldMime = $old->getMimeType();
281  $n = strrpos( $new, '.' );
282  $newExt = self::normalizeExtension( $n ? substr( $new, $n + 1 ) : '' );
283  $mimeMagic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
284 
285  return $mimeMagic->isMatchingExtension( $newExt, $oldMime );
286  }
287 
295  public function upgradeRow() {
296  }
297 
305  public static function splitMime( $mime ) {
306  if ( strpos( $mime, '/' ) !== false ) {
307  return explode( '/', $mime, 2 );
308  } else {
309  return [ $mime, 'unknown' ];
310  }
311  }
312 
320  public static function compare( File $a, File $b ) {
321  return strcmp( $a->getName(), $b->getName() );
322  }
323 
330  public function getName() {
331  if ( $this->name === null ) {
332  $this->assertRepoDefined();
333  $this->name = $this->repo->getNameFromTitle( $this->title );
334  }
335 
336  return $this->name;
337  }
338 
345  public function getExtension() {
346  if ( !isset( $this->extension ) ) {
347  $n = strrpos( $this->getName(), '.' );
348  $this->extension = self::normalizeExtension(
349  $n ? substr( $this->getName(), $n + 1 ) : '' );
350  }
351 
352  return $this->extension;
353  }
354 
360  public function getTitle() {
361  return $this->title;
362  }
363 
369  public function getOriginalTitle() {
370  if ( $this->redirected ) {
371  return $this->getRedirectedTitle();
372  }
373 
374  return $this->title;
375  }
376 
383  public function getUrl() {
384  if ( !isset( $this->url ) ) {
385  $this->assertRepoDefined();
386  $ext = $this->getExtension();
387  $this->url = $this->repo->getZoneUrl( 'public', $ext ) . '/' . $this->getUrlRel();
388  }
389 
390  return $this->url;
391  }
392 
400  public function getDescriptionShortUrl() {
401  return null;
402  }
403 
412  public function getFullUrl() {
413  return wfExpandUrl( $this->getUrl(), PROTO_RELATIVE );
414  }
415 
420  public function getCanonicalUrl() {
421  return wfExpandUrl( $this->getUrl(), PROTO_CANONICAL );
422  }
423 
427  public function getViewURL() {
428  if ( $this->mustRender() ) {
429  if ( $this->canRender() ) {
430  return $this->createThumb( $this->getWidth() );
431  } else {
432  wfDebug( __METHOD__ . ': supposed to render ' . $this->getName() .
433  ' (' . $this->getMimeType() . "), but can't!" );
434 
435  return $this->getUrl(); # hm... return NULL?
436  }
437  } else {
438  return $this->getUrl();
439  }
440  }
441 
456  public function getPath() {
457  if ( !isset( $this->path ) ) {
458  $this->assertRepoDefined();
459  $this->path = $this->repo->getZonePath( 'public' ) . '/' . $this->getRel();
460  }
461 
462  return $this->path;
463  }
464 
472  public function getLocalRefPath() {
473  $this->assertRepoDefined();
474  if ( !isset( $this->fsFile ) ) {
475  $starttime = microtime( true );
476  $this->fsFile = $this->repo->getLocalReference( $this->getPath() );
477 
478  $statTiming = microtime( true ) - $starttime;
479  MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
480  'media.thumbnail.generate.fetchoriginal', 1000 * $statTiming );
481 
482  if ( !$this->fsFile ) {
483  $this->fsFile = false; // null => false; cache negative hits
484  }
485  }
486 
487  return ( $this->fsFile )
488  ? $this->fsFile->getPath()
489  : false;
490  }
491 
503  public function getWidth( $page = 1 ) {
504  return false;
505  }
506 
518  public function getHeight( $page = 1 ) {
519  return false;
520  }
521 
531  public function getThumbnailBucket( $desiredWidth, $page = 1 ) {
533 
534  $imageWidth = $this->getWidth( $page );
535 
536  if ( $imageWidth === false ) {
537  return false;
538  }
539 
540  if ( $desiredWidth > $imageWidth ) {
541  return false;
542  }
543 
544  if ( !$wgThumbnailBuckets ) {
545  return false;
546  }
547 
548  $sortedBuckets = $wgThumbnailBuckets;
549 
550  sort( $sortedBuckets );
551 
552  foreach ( $sortedBuckets as $bucket ) {
553  if ( $bucket >= $imageWidth ) {
554  return false;
555  }
556 
557  if ( $bucket - $wgThumbnailMinimumBucketDistance > $desiredWidth ) {
558  return $bucket;
559  }
560  }
561 
562  // Image is bigger than any available bucket
563  return false;
564  }
565 
576  public function getDisplayWidthHeight( $maxWidth, $maxHeight, $page = 1 ) {
577  if ( !$maxWidth || !$maxHeight ) {
578  // should never happen
579  throw new MWException( 'Using a choice from $wgImageLimits that is 0x0' );
580  }
581 
582  $width = $this->getWidth( $page );
583  $height = $this->getHeight( $page );
584  if ( !$width || !$height ) {
585  return [ 0, 0 ];
586  }
587 
588  // Calculate the thumbnail size.
589  if ( $width <= $maxWidth && $height <= $maxHeight ) {
590  // Vectorized image, do nothing.
591  } elseif ( $width / $height >= $maxWidth / $maxHeight ) {
592  # The limiting factor is the width, not the height.
593  $height = round( $height * $maxWidth / $width );
594  $width = $maxWidth;
595  // Note that $height <= $maxHeight now.
596  } else {
597  $newwidth = floor( $width * $maxHeight / $height );
598  $height = round( $height * $newwidth / $width );
599  $width = $newwidth;
600  // Note that $height <= $maxHeight now, but might not be identical
601  // because of rounding.
602  }
603  return [ $width, $height ];
604  }
605 
614  public function getUser( $type = 'text' ) {
615  wfDeprecated( __METHOD__, '1.37' );
616  $user = $this->getUploader( self::RAW ) ?? User::newFromName( 'Unknown user' );
617  if ( $type === 'object' ) {
618  return User::newFromIdentity( $user );
619  } elseif ( $type === 'text' ) {
620  return $user->getName();
621  } elseif ( $type === 'id' ) {
622  return $user->getId();
623  }
624  throw new MWException( "Unknown type '$type'." );
625  }
626 
633  public function getLength() {
634  $handler = $this->getHandler();
635  if ( $handler ) {
636  return $handler->getLength( $this );
637  } else {
638  return 0;
639  }
640  }
641 
647  public function isVectorized() {
648  $handler = $this->getHandler();
649  if ( $handler ) {
650  return $handler->isVectorized( $this );
651  } else {
652  return false;
653  }
654  }
655 
667  public function getAvailableLanguages() {
668  $handler = $this->getHandler();
669  if ( $handler ) {
670  return $handler->getAvailableLanguages( $this );
671  } else {
672  return [];
673  }
674  }
675 
683  public function getMatchedLanguage( $userPreferredLanguage ) {
684  $handler = $this->getHandler();
685  if ( $handler ) {
687  $userPreferredLanguage,
689  );
690  }
691 
692  return null;
693  }
694 
702  public function getDefaultRenderLanguage() {
703  $handler = $this->getHandler();
704  if ( $handler ) {
705  return $handler->getDefaultRenderLanguage( $this );
706  } else {
707  return null;
708  }
709  }
710 
721  public function canAnimateThumbIfAppropriate() {
722  $handler = $this->getHandler();
723  if ( !$handler ) {
724  // We cannot handle image whatsoever, thus
725  // one would not expect it to be animated
726  // so true.
727  return true;
728  }
729 
730  return !$this->allowInlineDisplay()
731  // Image is not animated, so one would
732  // not expect thumb to be
733  || !$handler->isAnimatedImage( $this )
734  // Image is animated, but thumbnail isn't.
735  // This is unexpected to the user.
736  || $handler->canAnimateThumbnail( $this );
737  }
738 
746  public function getMetadata() {
747  return false;
748  }
749 
750  public function getHandlerState( string $key ) {
751  return $this->handlerState[$key] ?? null;
752  }
753 
754  public function setHandlerState( string $key, $value ) {
755  $this->handlerState[$key] = $value;
756  }
757 
764  public function getMetadataArray(): array {
765  return [];
766  }
767 
775  public function getMetadataItem( string $itemName ) {
776  $items = $this->getMetadataItems( [ $itemName ] );
777  return $items[$itemName] ?? null;
778  }
779 
787  public function getMetadataItems( array $itemNames ): array {
788  return array_intersect_key(
789  $this->getMetadataArray(),
790  array_fill_keys( $itemNames, true ) );
791  }
792 
799  public function getCommonMetaArray() {
800  $handler = $this->getHandler();
801 
802  if ( !$handler ) {
803  return false;
804  }
805 
806  return $handler->getCommonMetaArray( $this );
807  }
808 
816  public function convertMetadataVersion( $metadata, $version ) {
817  $handler = $this->getHandler();
818  if ( $handler ) {
819  return $handler->convertMetadataVersion( $metadata, $version );
820  } else {
821  return $metadata;
822  }
823  }
824 
832  public function getBitDepth() {
833  return 0;
834  }
835 
843  public function getSize() {
844  return false;
845  }
846 
855  public function getMimeType() {
856  return 'unknown/unknown';
857  }
858 
867  public function getMediaType() {
868  return MEDIATYPE_UNKNOWN;
869  }
870 
883  public function canRender() {
884  if ( !isset( $this->canRender ) ) {
885  $this->canRender = $this->getHandler() && $this->handler->canRender( $this ) && $this->exists();
886  }
887 
888  return $this->canRender;
889  }
890 
895  protected function getCanRender() {
896  return $this->canRender();
897  }
898 
910  public function mustRender() {
911  return $this->getHandler() && $this->handler->mustRender( $this );
912  }
913 
919  public function allowInlineDisplay() {
920  return $this->canRender();
921  }
922 
936  public function isSafeFile() {
937  if ( !isset( $this->isSafeFile ) ) {
938  $this->isSafeFile = $this->getIsSafeFileUncached();
939  }
940 
941  return $this->isSafeFile;
942  }
943 
949  protected function getIsSafeFile() {
950  return $this->isSafeFile();
951  }
952 
958  protected function getIsSafeFileUncached() {
959  global $wgTrustedMediaFormats;
960 
961  if ( $this->allowInlineDisplay() ) {
962  return true;
963  }
964  if ( $this->isTrustedFile() ) {
965  return true;
966  }
967 
968  $type = $this->getMediaType();
969  $mime = $this->getMimeType();
970 
971  if ( !$type || $type === MEDIATYPE_UNKNOWN ) {
972  return false; # unknown type, not trusted
973  }
974  if ( in_array( $type, $wgTrustedMediaFormats ) ) {
975  return true;
976  }
977 
978  if ( $mime === "unknown/unknown" ) {
979  return false; # unknown type, not trusted
980  }
981  if ( in_array( $mime, $wgTrustedMediaFormats ) ) {
982  return true;
983  }
984 
985  return false;
986  }
987 
1001  protected function isTrustedFile() {
1002  # this could be implemented to check a flag in the database,
1003  # look for signatures, etc
1004  return false;
1005  }
1006 
1017  public function load( $flags = 0 ) {
1018  }
1019 
1028  public function exists() {
1029  return $this->getPath() && $this->repo->fileExists( $this->path );
1030  }
1031 
1039  public function isVisible() {
1040  return $this->exists();
1041  }
1042 
1046  private function getTransformScript() {
1047  if ( !isset( $this->transformScript ) ) {
1048  $this->transformScript = false;
1049  if ( $this->repo ) {
1050  $script = $this->repo->getThumbScriptUrl();
1051  if ( $script ) {
1052  $this->transformScript = wfAppendQuery( $script, [ 'f' => $this->getName() ] );
1053  }
1054  }
1055  }
1056 
1057  return $this->transformScript;
1058  }
1059 
1067  public function getUnscaledThumb( $handlerParams = [] ) {
1068  $hp =& $handlerParams;
1069  $page = $hp['page'] ?? false;
1070  $width = $this->getWidth( $page );
1071  if ( !$width ) {
1072  return $this->iconThumb();
1073  }
1074  $hp['width'] = $width;
1075  // be sure to ignore any height specification as well (T64258)
1076  unset( $hp['height'] );
1077 
1078  return $this->transform( $hp );
1079  }
1080 
1091  public function thumbName( $params, $flags = 0 ) {
1092  $name = ( $this->repo && !( $flags & self::THUMB_FULL_NAME ) )
1093  ? $this->repo->nameForThumb( $this->getName() )
1094  : $this->getName();
1095 
1096  return $this->generateThumbName( $name, $params );
1097  }
1098 
1107  public function generateThumbName( $name, $params ) {
1108  if ( !$this->getHandler() ) {
1109  return null;
1110  }
1111  $extension = $this->getExtension();
1112  list( $thumbExt, ) = $this->getHandler()->getThumbType(
1113  $extension, $this->getMimeType(), $params );
1114  $thumbName = $this->getHandler()->makeParamString( $params );
1115 
1116  if ( $this->repo->supportsSha1URLs() ) {
1117  $thumbName .= '-' . $this->getSha1() . '.' . $thumbExt;
1118  } else {
1119  $thumbName .= '-' . $name;
1120 
1121  if ( $thumbExt != $extension ) {
1122  $thumbName .= ".$thumbExt";
1123  }
1124  }
1125 
1126  return $thumbName;
1127  }
1128 
1146  public function createThumb( $width, $height = -1 ) {
1147  $params = [ 'width' => $width ];
1148  if ( $height != -1 ) {
1149  $params['height'] = $height;
1150  }
1151  $thumb = $this->transform( $params );
1152  if ( !$thumb || $thumb->isError() ) {
1153  return '';
1154  }
1155 
1156  return $thumb->getUrl();
1157  }
1158 
1168  protected function transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags ) {
1169  global $wgIgnoreImageErrors;
1170 
1171  $handler = $this->getHandler();
1172  if ( $handler && $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
1173  return $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
1174  } else {
1175  return new MediaTransformError( 'thumbnail_error',
1176  $params['width'], 0, wfMessage( 'thumbnail-dest-create' ) );
1177  }
1178  }
1179 
1189  public function transform( $params, $flags = 0 ) {
1190  global $wgThumbnailEpoch;
1191 
1192  do {
1193  if ( !$this->canRender() ) {
1194  $thumb = $this->iconThumb();
1195  break; // not a bitmap or renderable image, don't try
1196  }
1197 
1198  // Get the descriptionUrl to embed it as comment into the thumbnail. T21791.
1199  $descriptionUrl = $this->getDescriptionUrl();
1200  if ( $descriptionUrl ) {
1201  $params['descriptionUrl'] = wfExpandUrl( $descriptionUrl, PROTO_CANONICAL );
1202  }
1203 
1204  $handler = $this->getHandler();
1205  $script = $this->getTransformScript();
1206  if ( $script && !( $flags & self::RENDER_NOW ) ) {
1207  // Use a script to transform on client request, if possible
1208  $thumb = $handler->getScriptedTransform( $this, $script, $params );
1209  if ( $thumb ) {
1210  break;
1211  }
1212  }
1213 
1214  $normalisedParams = $params;
1215  $handler->normaliseParams( $this, $normalisedParams );
1216 
1217  $thumbName = $this->thumbName( $normalisedParams );
1218  $thumbUrl = $this->getThumbUrl( $thumbName );
1219  $thumbPath = $this->getThumbPath( $thumbName ); // final thumb path
1220 
1221  if ( $this->repo ) {
1222  // Defer rendering if a 404 handler is set up...
1223  if ( $this->repo->canTransformVia404() && !( $flags & self::RENDER_NOW ) ) {
1224  // XXX: Pass in the storage path even though we are not rendering anything
1225  // and the path is supposed to be an FS path. This is due to getScalerType()
1226  // getting called on the path and clobbering $thumb->getUrl() if it's false.
1227  $thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
1228  break;
1229  }
1230  // Check if an up-to-date thumbnail already exists...
1231  wfDebug( __METHOD__ . ": Doing stat for $thumbPath" );
1232  if ( !( $flags & self::RENDER_FORCE ) && $this->repo->fileExists( $thumbPath ) ) {
1233  $timestamp = $this->repo->getFileTimestamp( $thumbPath );
1234  if ( $timestamp !== false && $timestamp >= $wgThumbnailEpoch ) {
1235  // XXX: Pass in the storage path even though we are not rendering anything
1236  // and the path is supposed to be an FS path. This is due to getScalerType()
1237  // getting called on the path and clobbering $thumb->getUrl() if it's false.
1238  $thumb = $handler->getTransform( $this, $thumbPath, $thumbUrl, $params );
1239  $thumb->setStoragePath( $thumbPath );
1240  break;
1241  }
1242  } elseif ( $flags & self::RENDER_FORCE ) {
1243  wfDebug( __METHOD__ . " forcing rendering per flag File::RENDER_FORCE" );
1244  }
1245 
1246  // If the backend is ready-only, don't keep generating thumbnails
1247  // only to return transformation errors, just return the error now.
1248  if ( $this->repo->getReadOnlyReason() !== false ) {
1249  $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
1250  break;
1251  }
1252 
1253  // Check to see if local transformation is disabled.
1254  if ( !$this->repo->canTransformLocally() ) {
1255  $thumb = new MediaTransformError(
1256  wfMessage(
1257  'thumbnail_error',
1258  'MediaWiki is configured to disallow local image scaling'
1259  ),
1260  $params['width'],
1261  0
1262  );
1263  break;
1264  }
1265  }
1266 
1267  $tmpFile = $this->makeTransformTmpFile( $thumbPath );
1268 
1269  if ( !$tmpFile ) {
1270  $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags );
1271  } else {
1272  $thumb = $this->generateAndSaveThumb( $tmpFile, $params, $flags );
1273  }
1274  } while ( false );
1275 
1276  return is_object( $thumb ) ? $thumb : false;
1277  }
1278 
1286  public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) {
1287  global $wgIgnoreImageErrors;
1288 
1289  if ( !$this->repo->canTransformLocally() ) {
1290  return new MediaTransformError(
1291  wfMessage(
1292  'thumbnail_error',
1293  'MediaWiki is configured to disallow local image scaling'
1294  ),
1295  $transformParams['width'],
1296  0
1297  );
1298  }
1299 
1300  $stats = MediaWikiServices::getInstance()->getStatsdDataFactory();
1301 
1302  $handler = $this->getHandler();
1303 
1304  $normalisedParams = $transformParams;
1305  $handler->normaliseParams( $this, $normalisedParams );
1306 
1307  $thumbName = $this->thumbName( $normalisedParams );
1308  $thumbUrl = $this->getThumbUrl( $thumbName );
1309  $thumbPath = $this->getThumbPath( $thumbName ); // final thumb path
1310 
1311  $tmpThumbPath = $tmpFile->getPath();
1312 
1313  if ( $handler->supportsBucketing() ) {
1314  $this->generateBucketsIfNeeded( $normalisedParams, $flags );
1315  }
1316 
1317  $starttime = microtime( true );
1318 
1319  // Actually render the thumbnail...
1320  $thumb = $handler->doTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
1321  $tmpFile->bind( $thumb ); // keep alive with $thumb
1322 
1323  $statTiming = microtime( true ) - $starttime;
1324  $stats->timing( 'media.thumbnail.generate.transform', 1000 * $statTiming );
1325 
1326  if ( !$thumb ) { // bad params?
1327  $thumb = false;
1328  } elseif ( $thumb->isError() ) { // transform error
1330  '@phan-var MediaTransformError $thumb';
1331  $this->lastError = $thumb->toText();
1332  // Ignore errors if requested
1333  if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
1334  $thumb = $handler->getTransform( $this, $tmpThumbPath, $thumbUrl, $transformParams );
1335  }
1336  } elseif ( $this->repo && $thumb->hasFile() && !$thumb->fileIsSource() ) {
1337  // Copy the thumbnail from the file system into storage...
1338 
1339  $starttime = microtime( true );
1340 
1341  $disposition = $this->getThumbDisposition( $thumbName );
1342  $status = $this->repo->quickImport( $tmpThumbPath, $thumbPath, $disposition );
1343  if ( $status->isOK() ) {
1344  $thumb->setStoragePath( $thumbPath );
1345  } else {
1346  $thumb = $this->transformErrorOutput( $thumbPath, $thumbUrl, $transformParams, $flags );
1347  }
1348 
1349  $statTiming = microtime( true ) - $starttime;
1350  $stats->timing( 'media.thumbnail.generate.store', 1000 * $statTiming );
1351 
1352  // Give extensions a chance to do something with this thumbnail...
1353  $this->getHookRunner()->onFileTransformed( $this, $thumb, $tmpThumbPath, $thumbPath );
1354  }
1355 
1356  return $thumb;
1357  }
1358 
1365  protected function generateBucketsIfNeeded( $params, $flags = 0 ) {
1366  if ( !$this->repo
1367  || !isset( $params['physicalWidth'] )
1368  || !isset( $params['physicalHeight'] )
1369  ) {
1370  return false;
1371  }
1372 
1373  $bucket = $this->getThumbnailBucket( $params['physicalWidth'] );
1374 
1375  if ( !$bucket || $bucket == $params['physicalWidth'] ) {
1376  return false;
1377  }
1378 
1379  $bucketPath = $this->getBucketThumbPath( $bucket );
1380 
1381  if ( $this->repo->fileExists( $bucketPath ) ) {
1382  return false;
1383  }
1384 
1385  $starttime = microtime( true );
1386 
1387  $params['physicalWidth'] = $bucket;
1388  $params['width'] = $bucket;
1389 
1390  $params = $this->getHandler()->sanitizeParamsForBucketing( $params );
1391 
1392  $tmpFile = $this->makeTransformTmpFile( $bucketPath );
1393 
1394  if ( !$tmpFile ) {
1395  return false;
1396  }
1397 
1398  $thumb = $this->generateAndSaveThumb( $tmpFile, $params, $flags );
1399 
1400  $buckettime = microtime( true ) - $starttime;
1401 
1402  if ( !$thumb || $thumb->isError() ) {
1403  return false;
1404  }
1405 
1406  $this->tmpBucketedThumbCache[$bucket] = $tmpFile->getPath();
1407  // For the caching to work, we need to make the tmp file survive as long as
1408  // this object exists
1409  $tmpFile->bind( $this );
1410 
1411  MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
1412  'media.thumbnail.generate.bucket', 1000 * $buckettime );
1413 
1414  return true;
1415  }
1416 
1422  public function getThumbnailSource( $params ) {
1423  if ( $this->repo
1424  && $this->getHandler()->supportsBucketing()
1425  && isset( $params['physicalWidth'] )
1426  && $bucket = $this->getThumbnailBucket( $params['physicalWidth'] )
1427  ) {
1428  if ( $this->getWidth() != 0 ) {
1429  $bucketHeight = round( $this->getHeight() * ( $bucket / $this->getWidth() ) );
1430  } else {
1431  $bucketHeight = 0;
1432  }
1433 
1434  // Try to avoid reading from storage if the file was generated by this script
1435  if ( isset( $this->tmpBucketedThumbCache[$bucket] ) ) {
1436  $tmpPath = $this->tmpBucketedThumbCache[$bucket];
1437 
1438  if ( file_exists( $tmpPath ) ) {
1439  return [
1440  'path' => $tmpPath,
1441  'width' => $bucket,
1442  'height' => $bucketHeight
1443  ];
1444  }
1445  }
1446 
1447  $bucketPath = $this->getBucketThumbPath( $bucket );
1448 
1449  if ( $this->repo->fileExists( $bucketPath ) ) {
1450  $fsFile = $this->repo->getLocalReference( $bucketPath );
1451 
1452  if ( $fsFile ) {
1453  return [
1454  'path' => $fsFile->getPath(),
1455  'width' => $bucket,
1456  'height' => $bucketHeight
1457  ];
1458  }
1459  }
1460  }
1461 
1462  // Thumbnailing a very large file could result in network saturation if
1463  // everyone does it at once.
1464  if ( $this->getSize() >= 1e7 ) { // 10 MB
1465  $work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $this->getName() ),
1466  [
1467  'doWork' => function () {
1468  return $this->getLocalRefPath();
1469  }
1470  ]
1471  );
1472  $srcPath = $work->execute();
1473  } else {
1474  $srcPath = $this->getLocalRefPath();
1475  }
1476 
1477  // Original file
1478  return [
1479  'path' => $srcPath,
1480  'width' => $this->getWidth(),
1481  'height' => $this->getHeight()
1482  ];
1483  }
1484 
1490  protected function getBucketThumbPath( $bucket ) {
1491  $thumbName = $this->getBucketThumbName( $bucket );
1492  return $this->getThumbPath( $thumbName );
1493  }
1494 
1500  protected function getBucketThumbName( $bucket ) {
1501  return $this->thumbName( [ 'physicalWidth' => $bucket ] );
1502  }
1503 
1509  protected function makeTransformTmpFile( $thumbPath ) {
1510  $thumbExt = FileBackend::extensionFromPath( $thumbPath );
1511  return MediaWikiServices::getInstance()->getTempFSFileFactory()
1512  ->newTempFSFile( 'transform_', $thumbExt );
1513  }
1514 
1520  public function getThumbDisposition( $thumbName, $dispositionType = 'inline' ) {
1521  $fileName = $this->name; // file name to suggest
1522  $thumbExt = FileBackend::extensionFromPath( $thumbName );
1523  if ( $thumbExt != '' && $thumbExt !== $this->getExtension() ) {
1524  $fileName .= ".$thumbExt";
1525  }
1526 
1527  return FileBackend::makeContentDisposition( $dispositionType, $fileName );
1528  }
1529 
1536  protected function migrateThumbFile( $thumbName ) {
1537  }
1538 
1545  public function getHandler() {
1546  if ( !isset( $this->handler ) ) {
1547  $this->handler = MediaHandler::getHandler( $this->getMimeType() );
1548  }
1549 
1550  return $this->handler;
1551  }
1552 
1558  public function iconThumb() {
1559  global $wgResourceBasePath, $IP;
1560  $assetsPath = "$wgResourceBasePath/resources/assets/file-type-icons/";
1561  $assetsDirectory = "$IP/resources/assets/file-type-icons/";
1562 
1563  $try = [ 'fileicon-' . $this->getExtension() . '.png', 'fileicon.png' ];
1564  foreach ( $try as $icon ) {
1565  if ( file_exists( $assetsDirectory . $icon ) ) { // always FS
1566  $params = [ 'width' => 120, 'height' => 120 ];
1567 
1568  return new ThumbnailImage( $this, $assetsPath . $icon, false, $params );
1569  }
1570  }
1571 
1572  return null;
1573  }
1574 
1580  public function getLastError() {
1581  return $this->lastError;
1582  }
1583 
1591  protected function getThumbnails() {
1592  return [];
1593  }
1594 
1603  public function purgeCache( $options = [] ) {
1604  }
1605 
1611  public function purgeDescription() {
1612  $title = $this->getTitle();
1613  if ( $title ) {
1615  $hcu = MediaWikiServices::getInstance()->getHtmlCacheUpdater();
1616  $hcu->purgeTitleUrls( $title, $hcu::PURGE_INTENT_TXROUND_REFLECTED );
1617  }
1618  }
1619 
1624  public function purgeEverything() {
1625  // Delete thumbnails and refresh file metadata cache
1626  $this->purgeCache();
1627  $this->purgeDescription();
1628  // Purge cache of all pages using this file
1629  $title = $this->getTitle();
1630  if ( $title ) {
1632  $title,
1633  'imagelinks',
1634  [ 'causeAction' => 'file-purge' ]
1635  );
1636  JobQueueGroup::singleton()->lazyPush( $job );
1637  }
1638  }
1639 
1652  public function getHistory( $limit = null, $start = null, $end = null, $inc = true ) {
1653  return [];
1654  }
1655 
1666  public function nextHistoryLine() {
1667  return false;
1668  }
1669 
1677  public function resetHistory() {
1678  }
1679 
1687  public function getHashPath() {
1688  if ( $this->hashPath === null ) {
1689  $this->assertRepoDefined();
1690  $this->hashPath = $this->repo->getHashPath( $this->getName() );
1691  }
1692 
1693  return $this->hashPath;
1694  }
1695 
1703  public function getRel() {
1704  return $this->getHashPath() . $this->getName();
1705  }
1706 
1715  public function getArchiveRel( $suffix = false ) {
1716  $path = 'archive/' . $this->getHashPath();
1717  if ( $suffix === false ) {
1718  $path = rtrim( $path, '/' );
1719  } else {
1720  $path .= $suffix;
1721  }
1722 
1723  return $path;
1724  }
1725 
1734  public function getThumbRel( $suffix = false ) {
1735  $path = $this->getRel();
1736  if ( $suffix !== false ) {
1737  $path .= '/' . $suffix;
1738  }
1739 
1740  return $path;
1741  }
1742 
1750  public function getUrlRel() {
1751  return $this->getHashPath() . rawurlencode( $this->getName() );
1752  }
1753 
1762  private function getArchiveThumbRel( $archiveName, $suffix = false ) {
1763  $path = $this->getArchiveRel( $archiveName );
1764  if ( $suffix !== false ) {
1765  $path .= '/' . $suffix;
1766  }
1767 
1768  return $path;
1769  }
1770 
1777  public function getArchivePath( $suffix = false ) {
1778  $this->assertRepoDefined();
1779 
1780  return $this->repo->getZonePath( 'public' ) . '/' . $this->getArchiveRel( $suffix );
1781  }
1782 
1790  public function getArchiveThumbPath( $archiveName, $suffix = false ) {
1791  $this->assertRepoDefined();
1792 
1793  return $this->repo->getZonePath( 'thumb' ) . '/' .
1794  $this->getArchiveThumbRel( $archiveName, $suffix );
1795  }
1796 
1804  public function getThumbPath( $suffix = false ) {
1805  $this->assertRepoDefined();
1806 
1807  return $this->repo->getZonePath( 'thumb' ) . '/' . $this->getThumbRel( $suffix );
1808  }
1809 
1816  public function getTranscodedPath( $suffix = false ) {
1817  $this->assertRepoDefined();
1818 
1819  return $this->repo->getZonePath( 'transcoded' ) . '/' . $this->getThumbRel( $suffix );
1820  }
1821 
1829  public function getArchiveUrl( $suffix = false ) {
1830  $this->assertRepoDefined();
1831  $ext = $this->getExtension();
1832  $path = $this->repo->getZoneUrl( 'public', $ext ) . '/archive/' . $this->getHashPath();
1833  if ( $suffix === false ) {
1834  $path = rtrim( $path, '/' );
1835  } else {
1836  $path .= rawurlencode( $suffix );
1837  }
1838 
1839  return $path;
1840  }
1841 
1850  public function getArchiveThumbUrl( $archiveName, $suffix = false ) {
1851  $this->assertRepoDefined();
1852  $ext = $this->getExtension();
1853  $path = $this->repo->getZoneUrl( 'thumb', $ext ) . '/archive/' .
1854  $this->getHashPath() . rawurlencode( $archiveName );
1855  if ( $suffix !== false ) {
1856  $path .= '/' . rawurlencode( $suffix );
1857  }
1858 
1859  return $path;
1860  }
1861 
1869  private function getZoneUrl( $zone, $suffix = false ) {
1870  $this->assertRepoDefined();
1871  $ext = $this->getExtension();
1872  $path = $this->repo->getZoneUrl( $zone, $ext ) . '/' . $this->getUrlRel();
1873  if ( $suffix !== false ) {
1874  $path .= '/' . rawurlencode( $suffix );
1875  }
1876 
1877  return $path;
1878  }
1879 
1887  public function getThumbUrl( $suffix = false ) {
1888  return $this->getZoneUrl( 'thumb', $suffix );
1889  }
1890 
1897  public function getTranscodedUrl( $suffix = false ) {
1898  return $this->getZoneUrl( 'transcoded', $suffix );
1899  }
1900 
1908  public function getVirtualUrl( $suffix = false ) {
1909  $this->assertRepoDefined();
1910  $path = $this->repo->getVirtualUrl() . '/public/' . $this->getUrlRel();
1911  if ( $suffix !== false ) {
1912  $path .= '/' . rawurlencode( $suffix );
1913  }
1914 
1915  return $path;
1916  }
1917 
1925  public function getArchiveVirtualUrl( $suffix = false ) {
1926  $this->assertRepoDefined();
1927  $path = $this->repo->getVirtualUrl() . '/public/archive/' . $this->getHashPath();
1928  if ( $suffix === false ) {
1929  $path = rtrim( $path, '/' );
1930  } else {
1931  $path .= rawurlencode( $suffix );
1932  }
1933 
1934  return $path;
1935  }
1936 
1944  public function getThumbVirtualUrl( $suffix = false ) {
1945  $this->assertRepoDefined();
1946  $path = $this->repo->getVirtualUrl() . '/thumb/' . $this->getUrlRel();
1947  if ( $suffix !== false ) {
1948  $path .= '/' . rawurlencode( $suffix );
1949  }
1950 
1951  return $path;
1952  }
1953 
1957  protected function isHashed() {
1958  $this->assertRepoDefined();
1959 
1960  return (bool)$this->repo->getHashLevels();
1961  }
1962 
1967  protected function readOnlyError() {
1968  throw new MWException( static::class . ': write operations are not supported' );
1969  }
1970 
1993  public function publish( $src, $flags = 0, array $options = [] ) {
1994  $this->readOnlyError();
1995  }
1996 
2001  public function formatMetadata( $context = false ) {
2002  if ( !$this->getHandler() ) {
2003  return false;
2004  }
2005 
2006  return $this->getHandler()->formatMetadata( $this, $context );
2007  }
2008 
2014  public function isLocal() {
2015  return $this->repo && $this->repo->isLocal();
2016  }
2017 
2023  public function getRepoName() {
2024  return $this->repo ? $this->repo->getName() : 'unknown';
2025  }
2026 
2033  public function getRepo() {
2034  return $this->repo;
2035  }
2036 
2044  public function isOld() {
2045  return false;
2046  }
2047 
2056  public function isDeleted( $field ) {
2057  return false;
2058  }
2059 
2066  public function getVisibility() {
2067  return 0;
2068  }
2069 
2075  public function wasDeleted() {
2076  $title = $this->getTitle();
2077 
2078  return $title && $title->hasDeletedEdits();
2079  }
2080 
2094  public function move( $target ) {
2095  $this->readOnlyError();
2096  }
2097 
2116  public function deleteFile( $reason, UserIdentity $user, $suppress = false ) {
2117  $this->readOnlyError();
2118  }
2119 
2134  public function restore( $versions = [], $unsuppress = false ) {
2135  $this->readOnlyError();
2136  }
2137 
2146  public function isMultipage() {
2147  return $this->getHandler() && $this->handler->isMultiPage( $this );
2148  }
2149 
2157  public function pageCount() {
2158  if ( !isset( $this->pageCount ) ) {
2159  if ( $this->getHandler() && $this->handler->isMultiPage( $this ) ) {
2160  $this->pageCount = $this->handler->pageCount( $this );
2161  } else {
2162  $this->pageCount = false;
2163  }
2164  }
2165 
2166  return $this->pageCount;
2167  }
2168 
2178  public static function scaleHeight( $srcWidth, $srcHeight, $dstWidth ) {
2179  // Exact integer multiply followed by division
2180  if ( $srcWidth == 0 ) {
2181  return 0;
2182  } else {
2183  return (int)round( $srcHeight * $dstWidth / $srcWidth );
2184  }
2185  }
2186 
2199  protected function getImageSize( $filePath ) {
2200  wfDeprecated( __METHOD__, '1.37' );
2201  if ( !$this->getHandler() ) {
2202  return false;
2203  }
2204 
2205  return $this->getHandler()->getImageSize( $this, $filePath );
2206  }
2207 
2215  public function getDescriptionUrl() {
2216  if ( $this->repo ) {
2217  return $this->repo->getDescriptionUrl( $this->getName() );
2218  } else {
2219  return false;
2220  }
2221  }
2222 
2231  public function getDescriptionText( Language $lang = null ) {
2232  global $wgLang;
2233 
2234  if ( !$this->repo || !$this->repo->fetchDescription ) {
2235  return false;
2236  }
2237 
2238  $lang = $lang ?? $wgLang;
2239 
2240  $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() );
2241  if ( $renderUrl ) {
2242  $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
2243  $key = $this->repo->getLocalCacheKey(
2244  'file-remote-description',
2245  $lang->getCode(),
2246  md5( $this->getName() )
2247  );
2248  $fname = __METHOD__;
2249 
2250  return $cache->getWithSetCallback(
2251  $key,
2252  $this->repo->descriptionCacheExpiry ?: $cache::TTL_UNCACHEABLE,
2253  static function ( $oldValue, &$ttl, array &$setOpts ) use ( $renderUrl, $fname ) {
2254  wfDebug( "Fetching shared description from $renderUrl" );
2255  $res = MediaWikiServices::getInstance()->getHttpRequestFactory()->
2256  get( $renderUrl, [], $fname );
2257  if ( !$res ) {
2258  $ttl = WANObjectCache::TTL_UNCACHEABLE;
2259  }
2260 
2261  return $res;
2262  }
2263  );
2264  }
2265 
2266  return false;
2267  }
2268 
2284  public function getUploader( int $audience = self::FOR_PUBLIC, Authority $performer = null ): ?UserIdentity {
2285  return null;
2286  }
2287 
2301  public function getDescription( $audience = self::FOR_PUBLIC, Authority $performer = null ) {
2302  return null;
2303  }
2304 
2311  public function getTimestamp() {
2312  $this->assertRepoDefined();
2313 
2314  return $this->repo->getFileTimestamp( $this->getPath() );
2315  }
2316 
2325  public function getDescriptionTouched() {
2326  return false;
2327  }
2328 
2335  public function getSha1() {
2336  $this->assertRepoDefined();
2337 
2338  return $this->repo->getFileSha1( $this->getPath() );
2339  }
2340 
2346  public function getStorageKey() {
2347  $hash = $this->getSha1();
2348  if ( !$hash ) {
2349  return false;
2350  }
2351  $ext = $this->getExtension();
2352  $dotExt = $ext === '' ? '' : ".$ext";
2353 
2354  return $hash . $dotExt;
2355  }
2356 
2366  public function userCan( $field, Authority $performer ) {
2367  return true;
2368  }
2369 
2374  public function getContentHeaders() {
2375  $handler = $this->getHandler();
2376  if ( $handler ) {
2377  return $handler->getContentHeaders( $this->getMetadataArray() );
2378  }
2379 
2380  return [];
2381  }
2382 
2386  public function getLongDesc() {
2387  $handler = $this->getHandler();
2388  if ( $handler ) {
2389  return $handler->getLongDesc( $this );
2390  } else {
2391  return MediaHandler::getGeneralLongDesc( $this );
2392  }
2393  }
2394 
2398  public function getShortDesc() {
2399  $handler = $this->getHandler();
2400  if ( $handler ) {
2401  return $handler->getShortDesc( $this );
2402  } else {
2403  return MediaHandler::getGeneralShortDesc( $this );
2404  }
2405  }
2406 
2410  public function getDimensionsString() {
2411  $handler = $this->getHandler();
2412  if ( $handler ) {
2413  return $handler->getDimensionsString( $this );
2414  } else {
2415  return '';
2416  }
2417  }
2418 
2422  public function getRedirected() {
2423  return $this->redirected;
2424  }
2425 
2429  protected function getRedirectedTitle() {
2430  if ( $this->redirected ) {
2431  if ( !$this->redirectTitle ) {
2432  $this->redirectTitle = Title::makeTitle( NS_FILE, $this->redirected );
2433  }
2434 
2435  return $this->redirectTitle;
2436  }
2437 
2438  return null;
2439  }
2440 
2445  public function redirectedFrom( $from ) {
2446  $this->redirected = $from;
2447  }
2448 
2453  public function isMissing() {
2454  return false;
2455  }
2456 
2462  public function isCacheable() {
2463  return true;
2464  }
2465 
2470  protected function assertRepoDefined() {
2471  if ( !( $this->repo instanceof $this->repoClass ) ) {
2472  throw new MWException( "A {$this->repoClass} object is not set for this File.\n" );
2473  }
2474  }
2475 
2480  protected function assertTitleDefined() {
2481  if ( !( $this->title instanceof Title ) ) {
2482  throw new MWException( "A Title object is not set for this File.\n" );
2483  }
2484  }
2485 
2490  public function isExpensiveToThumbnail() {
2491  $handler = $this->getHandler();
2492  return $handler ? $handler->isExpensiveToThumbnail( $this ) : false;
2493  }
2494 
2501  public function isTransformedLocally() {
2502  return true;
2503  }
2504 }
File\getExtension
getExtension()
Get the file extension, e.g.
Definition: File.php:345
File\getContentHeaders
getContentHeaders()
Definition: File.php:2374
File\THUMB_FULL_NAME
const THUMB_FULL_NAME
Definition: File.php:91
Page\PageIdentity
Interface for objects (potentially) representing an editable wiki page.
Definition: PageIdentity.php:64
File\getDisplayWidthHeight
getDisplayWidthHeight( $maxWidth, $maxHeight, $page=1)
Get the width and height to display image at.
Definition: File.php:576
File\wasDeleted
wasDeleted()
Was this file ever deleted from the wiki?
Definition: File.php:2075
File\redirectedFrom
redirectedFrom( $from)
Definition: File.php:2445
File\getDescriptionTouched
getDescriptionTouched()
Returns the timestamp (in TS_MW format) of the last change of the description page.
Definition: File.php:2325
File\getPath
getPath()
Return the storage path to the file.
Definition: File.php:456
MediaTransformError
Basic media transform error class.
Definition: MediaTransformError.php:31
ThumbnailImage
Media transform output for images.
Definition: ThumbnailImage.php:29
File\checkExtensionCompatibility
static checkExtensionCompatibility(File $old, $new)
Checks if file extensions are compatible.
Definition: File.php:279
File\$repo
FileRepo LocalRepo ForeignAPIRepo bool $repo
Some member variables can be lazy-initialised using __get().
Definition: File.php:113
MediaHandler\getCommonMetaArray
getCommonMetaArray(File $file)
Get an array of standard (FormatMetadata type) metadata values.
Definition: MediaHandler.php:409
File\canAnimateThumbIfAppropriate
canAnimateThumbIfAppropriate()
Will the thumbnail be animated if one would expect it to be.
Definition: File.php:721
MediaHandler\normaliseParams
normaliseParams( $image, &$params)
Changes the parameter array as necessary, ready for transformation.
File\getArchiveThumbPath
getArchiveThumbPath( $archiveName, $suffix=false)
Get the path of an archived file's thumbs, or a particular thumb if $suffix is specified.
Definition: File.php:1790
File\getHeight
getHeight( $page=1)
Return the height of the image.
Definition: File.php:518
File\DELETED_USER
const DELETED_USER
Definition: File.php:72
File\$tmpBucketedThumbCache
array $tmpBucketedThumbCache
Cache of tmp filepaths pointing to generated bucket thumbnails, keyed by width.
Definition: File.php:171
File\getDescriptionShortUrl
getDescriptionShortUrl()
Get short description URL for a files based on the page ID.
Definition: File.php:400
File\getBitDepth
getBitDepth()
Return the bit depth of the file Overridden by LocalFile STUB.
Definition: File.php:832
File\getUrlRel
getUrlRel()
Get urlencoded path of the file relative to the public zone root.
Definition: File.php:1750
File\migrateThumbFile
migrateThumbFile( $thumbName)
Hook into transform() to allow migration of thumbnail files STUB.
Definition: File.php:1536
File\isMultipage
isMultipage()
Returns 'true' if this file is a type which supports multiple pages, e.g.
Definition: File.php:2146
File\getFullUrl
getFullUrl()
Return a fully-qualified URL to the file.
Definition: File.php:412
File\getZoneUrl
getZoneUrl( $zone, $suffix=false)
Get the URL of the zone directory, or a particular file if $suffix is specified.
Definition: File.php:1869
File\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: File.php:73
File\getMetadata
getMetadata()
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB.
Definition: File.php:746
File\RAW
const RAW
Definition: File.php:88
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:193
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:37
File\getIsSafeFileUncached
getIsSafeFileUncached()
Uncached accessor.
Definition: File.php:958
File\$transformScript
string $transformScript
URL of transformscript (for example thumb.php)
Definition: File.php:154
File\getRel
getRel()
Get the path of the file relative to the public zone root.
Definition: File.php:1703
File\isExpensiveToThumbnail
isExpensiveToThumbnail()
True if creating thumbnails from the file is large or otherwise resource-intensive.
Definition: File.php:2490
File\isMissing
isMissing()
Definition: File.php:2453
File\getOriginalTitle
getOriginalTitle()
Return the title used to find this file.
Definition: File.php:369
File\getUploader
getUploader(int $audience=self::FOR_PUBLIC, Authority $performer=null)
Get the identity of the file uploader.
Definition: File.php:2284
File\$redirectTitle
Title $redirectTitle
Definition: File.php:157
MediaHandler\getShortDesc
getShortDesc( $file)
Short description.
Definition: MediaHandler.php:814
File\getLastError
getLastError()
Get last thumbnailing error.
Definition: File.php:1580
File\getTimestamp
getTimestamp()
Get the 14-character timestamp of the file upload.
Definition: File.php:2311
File\getSha1
getSha1()
Get the SHA-1 base 36 hash of the file.
Definition: File.php:2335
File\convertMetadataVersion
convertMetadataVersion( $metadata, $version)
get versioned metadata
Definition: File.php:816
File\getUser
getUser( $type='text')
Returns ID or name of user who uploaded the file STUB.
Definition: File.php:614
FileBackend\extensionFromPath
static extensionFromPath( $path, $case='lowercase')
Get the final extension from a storage or FS path.
Definition: FileBackend.php:1599
File\RENDER_FORCE
const RENDER_FORCE
Force rendering even if thumbnail already exist and using RENDER_NOW I.e.
Definition: File.php:81
File\getUrl
getUrl()
Return the URL of the file.
Definition: File.php:383
File\compare
static compare(File $a, File $b)
Callback for usort() to do file sorts by name.
Definition: File.php:320
MediaHandler\getMatchedLanguage
getMatchedLanguage( $userPreferredLanguage, array $availableLanguages)
When overridden in a descendant class, returns a language code most suiting.
Definition: MediaHandler.php:1040
File\getTranscodedUrl
getTranscodedUrl( $suffix=false)
Get the URL of the transcoded directory, or a particular file if $suffix is specified.
Definition: File.php:1897
File\getThumbnailSource
getThumbnailSource( $params)
Returns the most appropriate source image for the thumbnail, given a target thumbnail size.
Definition: File.php:1422
MEDIATYPE_UNKNOWN
const MEDIATYPE_UNKNOWN
Definition: defines.php:26
File\getWidth
getWidth( $page=1)
Return the width of the image.
Definition: File.php:503
User\newFromName
static newFromName( $name, $validate='valid')
Definition: User.php:606
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1182
File\getMediaType
getMediaType()
Return the type of the media in the file.
Definition: File.php:867
File\restore
restore( $versions=[], $unsuppress=false)
Restore all or specified deleted revisions to the given file.
Definition: File.php:2134
User\newFromIdentity
static newFromIdentity(UserIdentity $identity)
Returns a User object corresponding to the given UserIdentity.
Definition: User.php:683
File\getCanonicalUrl
getCanonicalUrl()
Definition: File.php:420
File\splitMime
static splitMime( $mime)
Split an internet media type into its two components; if not a two-part name, set the minor type to '...
Definition: File.php:305
File\isVisible
isVisible()
Returns true if file exists in the repository and can be included in a page.
Definition: File.php:1039
PoolCounterWorkViaCallback
Convenience class for dealing with PoolCounters using callbacks.
Definition: PoolCounterWorkViaCallback.php:31
$wgThumbnailBuckets
$wgThumbnailBuckets
When defined, is an array of image widths used as buckets for thumbnail generation.
Definition: DefaultSettings.php:1664
MediaHandler\getLongDesc
getLongDesc( $file)
Long description.
Definition: MediaHandler.php:826
$res
$res
Definition: testCompression.php:57
File\getMetadataArray
getMetadataArray()
Get the unserialized handler-specific metadata STUB.
Definition: File.php:764
IDBAccessObject
Interface for database access objects.
Definition: IDBAccessObject.php:57
File\$repoClass
string $repoClass
Required Repository class type.
Definition: File.php:168
File\getArchiveRel
getArchiveRel( $suffix=false)
Get the path of an archived file relative to the public zone root.
Definition: File.php:1715
$wgLang
$wgLang
Definition: Setup.php:831
File\isDeleted
isDeleted( $field)
Is this file a "deleted" file in a private archive? STUB.
Definition: File.php:2056
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:39
File\setHandlerState
setHandlerState(string $key, $value)
Set a value.
Definition: File.php:754
File\getVisibility
getVisibility()
Return the deletion bitfield STUB.
Definition: File.php:2066
$wgThumbnailMinimumBucketDistance
$wgThumbnailMinimumBucketDistance
When using thumbnail buckets as defined above, this sets the minimum distance to the bucket above the...
Definition: DefaultSettings.php:1681
MediaHandler\supportsBucketing
supportsBucketing()
Returns whether or not this handler supports the chained generation of thumbnails according to bucket...
Definition: MediaHandler.php:1097
File\FOR_PUBLIC
const FOR_PUBLIC
Definition: File.php:86
File\normalizeTitle
static normalizeTitle( $title, $exception=false)
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
Definition: File.php:205
MediaHandler\getAvailableLanguages
getAvailableLanguages(File $file)
Get list of languages file can be viewed in.
Definition: MediaHandler.php:1025
File\exists
exists()
Returns true if file exists in the repository.
Definition: File.php:1028
File\getThumbVirtualUrl
getThumbVirtualUrl( $suffix=false)
Get the virtual URL for a thumbnail file or directory.
Definition: File.php:1944
$wgThumbnailEpoch
$wgThumbnailEpoch
If rendered thumbnail files are older than this timestamp, they will be rerendered on demand as if th...
Definition: DefaultSettings.php:1440
File\upgradeRow
upgradeRow()
Upgrade the database row if there is one Called by ImagePage STUB.
Definition: File.php:295
Title\castFromPageIdentity
static castFromPageIdentity(?PageIdentity $pageIdentity)
Return a Title for a given PageIdentity.
Definition: Title.php:332
FileRepo
Base class for file repositories.
Definition: FileRepo.php:45
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:422
File\$path
string $path
The storage path corresponding to one of the zones.
Definition: File.php:143
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition: MediaWikiServices.php:254
File\isCacheable
isCacheable()
Check if this file object is small and can be cached.
Definition: File.php:2462
File\$canRender
bool $canRender
Whether the output of transform() for this file is likely to be valid.
Definition: File.php:160
File\getBucketThumbName
getBucketThumbName( $bucket)
Returns the name of the thumb for a given bucket.
Definition: File.php:1500
PROTO_RELATIVE
const PROTO_RELATIVE
Definition: Defines.php:194
File
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition: File.php:66
MediaHandler\isExpensiveToThumbnail
isExpensiveToThumbnail( $file)
True if creating thumbnails from the file is large or otherwise resource-intensive.
Definition: MediaHandler.php:1085
File\getMimeType
getMimeType()
Returns the MIME type of the file.
Definition: File.php:855
File\getDefaultRenderLanguage
getDefaultRenderLanguage()
In files that support multiple language, what is the default language to use if none specified.
Definition: File.php:702
File\$url
string $url
The URL corresponding to one of the four basic zones.
Definition: File.php:134
MWException
MediaWiki exception.
Definition: MWException.php:29
File\getLocalRefPath
getLocalRefPath()
Get an FS copy or original of this file and return the path.
Definition: File.php:472
File\DELETED_COMMENT
const DELETED_COMMENT
Definition: File.php:71
File\transformErrorOutput
transformErrorOutput( $thumbPath, $thumbUrl, $params, $flags)
Return either a MediaTransformError or placeholder thumbnail (if $wgIgnoreImageErrors)
Definition: File.php:1168
File\getIsSafeFile
getIsSafeFile()
Accessor for __get()
Definition: File.php:949
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Definition: GlobalFunctions.php:997
File\$redirectedTitle
Title $redirectedTitle
Definition: File.php:125
File\getThumbPath
getThumbPath( $suffix=false)
Get the path of the thumbnail directory, or a particular file if $suffix is specified.
Definition: File.php:1804
File\pageCount
pageCount()
Returns the number of pages of a multipage document, or false for documents which aren't multipage do...
Definition: File.php:2157
File\nextHistoryLine
nextHistoryLine()
Return the history of this file, line by line.
Definition: File.php:1666
File\normalizeExtension
static normalizeExtension( $extension)
Normalize a file extension to the common form, making it lowercase and checking some synonyms,...
Definition: File.php:254
PoolCounterWork\execute
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
Definition: PoolCounterWork.php:127
File\getMetadataItem
getMetadataItem(string $itemName)
Get a specific element of the unserialized handler-specific metadata.
Definition: File.php:775
File\getArchiveVirtualUrl
getArchiveVirtualUrl( $suffix=false)
Get the public zone virtual URL for an archived version source file.
Definition: File.php:1925
MediaHandler\canAnimateThumbnail
canAnimateThumbnail( $file)
If the material is animated, we can animate the thumbnail.
Definition: MediaHandler.php:574
File\purgeCache
purgeCache( $options=[])
Purge shared caches such as thumbnails and DB data caching STUB Overridden by LocalFile.
Definition: File.php:1603
File\getTransformScript
getTransformScript()
Definition: File.php:1046
File\userCan
userCan( $field, Authority $performer)
Determine if the current user is allowed to view a particular field of this file, if it's marked as d...
Definition: File.php:2366
File\FOR_THIS_USER
const FOR_THIS_USER
Definition: File.php:87
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:651
File\getArchiveThumbRel
getArchiveThumbRel( $archiveName, $suffix=false)
Get the path, relative to the thumbnail zone root, for an archived file's thumbs directory or a speci...
Definition: File.php:1762
PROTO_CANONICAL
const PROTO_CANONICAL
Definition: Defines.php:196
File\getStorageKey
getStorageKey()
Get the deletion archive key, "<sha1>.<ext>".
Definition: File.php:2346
File\__construct
__construct( $title, $repo)
Call this constructor from child classes.
Definition: File.php:187
File\isHashed
isHashed()
Definition: File.php:1957
File\generateAndSaveThumb
generateAndSaveThumb( $tmpFile, $transformParams, $flags)
Generates a thumbnail according to the given parameters and saves it to storage.
Definition: File.php:1286
File\getHandlerState
getHandlerState(string $key)
Get a value, or null if it does not exist.
Definition: File.php:750
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:894
File\getCommonMetaArray
getCommonMetaArray()
Like getMetadata but returns a handler independent array of common values.
Definition: File.php:799
File\getThumbRel
getThumbRel( $suffix=false)
Get the path, relative to the thumbnail zone root, of the thumbnail directory or a particular file if...
Definition: File.php:1734
File\isTransformedLocally
isTransformedLocally()
Whether the thumbnails created on the same server as this code is running.
Definition: File.php:2501
MediaHandler\getDimensionsString
getDimensionsString( $file)
Shown in file history box on image description page.
Definition: MediaHandler.php:879
MediaWiki\Permissions\Authority
This interface represents the authority associated the current execution context, such as a web reque...
Definition: Authority.php:37
File\canRender
canRender()
Checks if the output of transform() for this file is likely to be valid.
Definition: File.php:883
File\$fsFile
FSFile bool $fsFile
False if undefined.
Definition: File.php:128
File\getRedirectedTitle
getRedirectedTitle()
Definition: File.php:2429
MediaHandler\convertMetadataVersion
convertMetadataVersion( $metadata, $version=1)
Convert metadata version.
Definition: MediaHandler.php:308
MediaHandler\getGeneralShortDesc
static getGeneralShortDesc( $file)
Used instead of getShortDesc if there is no handler registered for file.
Definition: MediaHandler.php:836
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:677
File\getAvailableLanguages
getAvailableLanguages()
Gives a (possibly empty) list of languages to render the file in.
Definition: File.php:667
File\iconThumb
iconThumb()
Get a ThumbnailImage representing a file type icon.
Definition: File.php:1558
File\purgeDescription
purgeDescription()
Purge the file description page, but don't go after pages using the file.
Definition: File.php:1611
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:52
File\getMetadataItems
getMetadataItems(array $itemNames)
Get multiple elements of the unserialized handler-specific metadata.
Definition: File.php:787
File\isOld
isOld()
Returns true if the image is an old version STUB.
Definition: File.php:2044
File\$handler
MediaHandler $handler
Definition: File.php:131
File\assertTitleDefined
assertTitleDefined()
Assert that $this->title is set to a Title.
Definition: File.php:2480
$wgIgnoreImageErrors
$wgIgnoreImageErrors
If set, inline scaled images will still produce "<img>" tags ready for output instead of showing an e...
Definition: DefaultSettings.php:1461
MediaHandler\getTransform
getTransform( $image, $dstPath, $dstUrl, $params)
Get a MediaTransformOutput object representing the transformed output.
Definition: MediaHandler.php:444
File\getHistory
getHistory( $limit=null, $start=null, $end=null, $inc=true)
Return a fragment of the history of file.
Definition: File.php:1652
Title\hasDeletedEdits
hasDeletedEdits()
Is there a version of this page in the deletion archive?
Definition: Title.php:2868
File\generateThumbName
generateThumbName( $name, $params)
Generate a thumbnail file name from a name and specified parameters.
Definition: File.php:1107
HTMLCacheUpdateJob\newForBacklinks
static newForBacklinks(PageReference $page, $table, $params=[])
Definition: HTMLCacheUpdateJob.php:61
File\formatMetadata
formatMetadata( $context=false)
Definition: File.php:2001
File\getDescription
getDescription( $audience=self::FOR_PUBLIC, Authority $performer=null)
Get description of file revision STUB.
Definition: File.php:2301
File\createThumb
createThumb( $width, $height=-1)
Create a thumbnail of the image having the specified width/height.
Definition: File.php:1146
File\$title
Title string bool $title
Definition: File.php:116
File\getDescriptionUrl
getDescriptionUrl()
Get the URL of the image description page.
Definition: File.php:2215
File\getArchiveThumbUrl
getArchiveThumbUrl( $archiveName, $suffix=false)
Get the URL of the archived file's thumbs, or a particular thumb if $suffix is specified.
Definition: File.php:1850
File\getName
getName()
Return the name of this file.
Definition: File.php:330
File\getArchiveUrl
getArchiveUrl( $suffix=false)
Get the URL of the archive directory, or a particular file if $suffix is specified.
Definition: File.php:1829
File\getThumbDisposition
getThumbDisposition( $thumbName, $dispositionType='inline')
Definition: File.php:1520
FSFile
Class representing a non-directory file on the file system.
Definition: FSFile.php:32
MediaHandler\doTransform
doTransform( $image, $dstPath, $dstUrl, $params, $flags=0)
Get a MediaTransformOutput object representing the transformed output.
File\isSafeFile
isSafeFile()
Determines if this media file is in a format that is unlikely to contain viruses or malicious content...
Definition: File.php:936
File\$pageCount
int false $pageCount
Number of pages of a multipage document, or false for documents which aren't multipage documents.
Definition: File.php:151
File\getRepoName
getRepoName()
Returns the name of the repository.
Definition: File.php:2023
File\DELETE_SOURCE
const DELETE_SOURCE
Definition: File.php:83
File\$handlerState
array $handlerState
Definition: File.php:174
$wgResourceBasePath
$wgResourceBasePath
The default 'remoteBasePath' value for instances of ResourceLoaderFileModule.
Definition: DefaultSettings.php:4411
File\publish
publish( $src, $flags=0, array $options=[])
Move or copy a file to its public location.
Definition: File.php:1993
File\$extension
string $extension
File extension.
Definition: File.php:137
File\getBucketThumbPath
getBucketThumbPath( $bucket)
Returns the repo path of the thumb for a given bucket.
Definition: File.php:1490
File\$hashPath
string $hashPath
Relative path including trailing slash.
Definition: File.php:146
File\scaleHeight
static scaleHeight( $srcWidth, $srcHeight, $dstWidth)
Calculate the height of a thumbnail using the source and destination width.
Definition: File.php:2178
File\RENDER_NOW
const RENDER_NOW
Force rendering in the current process.
Definition: File.php:76
File\transform
transform( $params, $flags=0)
Transform a media file.
Definition: File.php:1189
File\getTitle
getTitle()
Return the associated title object.
Definition: File.php:360
File\readOnlyError
readOnlyError()
Definition: File.php:1967
Title
Represents a title within MediaWiki.
Definition: Title.php:48
ForeignAPIRepo
A foreign repository for a remote MediaWiki accessible through api.php requests.
Definition: ForeignAPIRepo.php:42
File\$isSafeFile
bool $isSafeFile
Whether this media file is in a format that is unlikely to contain viruses or malicious content.
Definition: File.php:165
JobQueueGroup\singleton
static singleton( $domain=false)
Definition: JobQueueGroup.php:114
File\getThumbnailBucket
getThumbnailBucket( $desiredWidth, $page=1)
Return the smallest bucket from $wgThumbnailBuckets which is at least $wgThumbnailMinimumBucketDistan...
Definition: File.php:531
MediaHandler\getContentHeaders
getContentHeaders( $metadata)
Get useful response headers for GET/HEAD requests for a file with the given metadata.
Definition: MediaHandler.php:1197
$cache
$cache
Definition: mcc.php:33
File\move
move( $target)
Move file to the new title.
Definition: File.php:2094
File\assertRepoDefined
assertRepoDefined()
Assert that $this->repo is set to a valid FileRepo instance.
Definition: File.php:2470
File\getShortDesc
getShortDesc()
Definition: File.php:2398
$job
if(count( $args)< 1) $job
Definition: recompressTracked.php:49
File\getLength
getLength()
Get the duration of a media file in seconds.
Definition: File.php:633
File\getLongDesc
getLongDesc()
Definition: File.php:2386
File\isLocal
isLocal()
Returns true if the file comes from the local file repository.
Definition: File.php:2014
File\getDescriptionText
getDescriptionText(Language $lang=null)
Get the HTML text of the description page, if available.
Definition: File.php:2231
MediaHandler\getHandler
static getHandler( $type)
Get a MediaHandler for a given MIME type from the instance cache.
Definition: MediaHandler.php:53
File\getCanRender
getCanRender()
Accessor for __get()
Definition: File.php:895
MediaHandler\isAnimatedImage
isAnimatedImage( $file)
The material is an image, and is animated.
Definition: MediaHandler.php:561
MediaHandler\isVectorized
isVectorized( $file)
The material is vectorized and thus scaling is lossless.
Definition: MediaHandler.php:547
File\mustRender
mustRender()
Return true if the file is of a type that can't be directly rendered by typical browsers and needs to...
Definition: File.php:910
File\load
load( $flags=0)
Load any lazy-loaded file object fields from source.
Definition: File.php:1017
File\resetHistory
resetHistory()
Reset the history pointer to the first element of the history.
Definition: File.php:1677
MediaHandler\getScriptedTransform
getScriptedTransform( $image, $script, $params)
Get a MediaTransformOutput object representing an alternate of the transformed output which will call...
Definition: MediaHandler.php:428
$ext
if(!is_readable( $file)) $ext
Definition: router.php:48
File\getRedirected
getRedirected()
Definition: File.php:2422
File\$name
string $name
The name of a file from its title object.
Definition: File.php:140
File\DELETED_FILE
const DELETED_FILE
Definition: File.php:70
File\getMatchedLanguage
getMatchedLanguage( $userPreferredLanguage)
Get the language code from the available languages for this file that matches the language requested ...
Definition: File.php:683
MediaHandler\getGeneralLongDesc
static getGeneralLongDesc( $file)
Used instead of getLongDesc if there is no handler registered for file.
Definition: MediaHandler.php:848
Title\castFromLinkTarget
static castFromLinkTarget( $linkTarget)
Same as newFromLinkTarget, but if passed null, returns null.
Definition: Title.php:319
File\getRepo
getRepo()
Returns the repository.
Definition: File.php:2033
File\deleteFile
deleteFile( $reason, UserIdentity $user, $suppress=false)
Delete all versions of the file.
Definition: File.php:2116
File\allowInlineDisplay
allowInlineDisplay()
Alias for canRender()
Definition: File.php:919
Title\invalidateCache
invalidateCache( $purgeTime=null)
Updates page_touched for this page; called from LinksUpdate.php.
Definition: Title.php:3730
$mime
$mime
Definition: router.php:60
NS_FILE
const NS_FILE
Definition: Defines.php:70
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
File\getThumbUrl
getThumbUrl( $suffix=false)
Get the URL of the thumbnail directory, or a particular file if $suffix is specified.
Definition: File.php:1887
File\isVectorized
isVectorized()
Return true if the file is vectorized.
Definition: File.php:647
File\getDimensionsString
getDimensionsString()
Definition: File.php:2410
File\getHandler
getHandler()
Get a MediaHandler instance for this file.
Definition: File.php:1545
File\__get
__get( $name)
Definition: File.php:235
$wgTrustedMediaFormats
$wgTrustedMediaFormats
list of trusted media-types and MIME types.
Definition: DefaultSettings.php:1191
$IP
$IP
Definition: WebStart.php:49
File\generateBucketsIfNeeded
generateBucketsIfNeeded( $params, $flags=0)
Generates chained bucketed thumbnails if needed.
Definition: File.php:1365
File\thumbName
thumbName( $params, $flags=0)
Return the file name of a thumbnail with the specified parameters.
Definition: File.php:1091
File\$lastError
string $lastError
Text of last error.
Definition: File.php:119
File\$redirected
string $redirected
Main part of the title, with underscores (Title::getDBkey)
Definition: File.php:122
MediaHandlerState
An interface to support process-local caching of handler data associated with a given file.
Definition: MediaHandlerState.php:10
File\getImageSize
getImageSize( $filePath)
Get an image size array like that returned by getImageSize(), or false if it can't be determined.
Definition: File.php:2199
FSFile\getPath
getPath()
Returns the file system path.
Definition: FSFile.php:53
File\makeTransformTmpFile
makeTransformTmpFile( $thumbPath)
Creates a temp FS file with the same extension and the thumbnail.
Definition: File.php:1509
File\getArchivePath
getArchivePath( $suffix=false)
Get the path of the archived file.
Definition: File.php:1777
Language
Internationalisation code See https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation for more...
Definition: Language.php:42
File\purgeEverything
purgeEverything()
Purge metadata and all affected pages when the file is created, deleted, or majorly updated.
Definition: File.php:1624
File\getUnscaledThumb
getUnscaledThumb( $handlerParams=[])
Get a ThumbnailImage which is the same size as the source.
Definition: File.php:1067
File\getHashPath
getHashPath()
Get the filename hash component of the directory including trailing slash, e.g.
Definition: File.php:1687
File\isTrustedFile
isTrustedFile()
Returns true if the file is flagged as trusted.
Definition: File.php:1001
LocalRepo
A repository that stores files in the local filesystem and registers them in the wiki's own database.
Definition: LocalRepo.php:41
File\getSize
getSize()
Return the size of the image file, in bytes Overridden by LocalFile, UnregisteredLocalFile STUB.
Definition: File.php:843
MediaHandler
Base media handler class.
Definition: MediaHandler.php:37
MediaHandler\getLength
getLength( $file)
If its an audio file, return the length of the file.
Definition: MediaHandler.php:1074
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:474
File\getThumbnails
getThumbnails()
Get all thumbnail names previously generated for this file STUB Overridden by LocalFile.
Definition: File.php:1591
MediaHandler\getDefaultRenderLanguage
getDefaultRenderLanguage(File $file)
On file types that support renderings in multiple languages, which language is used by default if uns...
Definition: MediaHandler.php:1058
File\getTranscodedPath
getTranscodedPath( $suffix=false)
Get the path of the transcoded directory, or a particular file if $suffix is specified.
Definition: File.php:1816
File\getViewURL
getViewURL()
Definition: File.php:427
File\getVirtualUrl
getVirtualUrl( $suffix=false)
Get the public zone virtual URL for a current version source file.
Definition: File.php:1908
$type
$type
Definition: testCompression.php:52
FileBackend\makeContentDisposition
static makeContentDisposition( $type, $filename='')
Build a Content-Disposition header value per RFC 6266.
Definition: FileBackend.php:1634