*/
function canRender() {
if ( !isset( $this->canRender ) ) {
- $this->canRender = $this->getHandler() && $this->handler->canRender( $this );
+ $this->canRender = $this->getHandler() && $this->handler->canRender( $this ) && $this->exists();
}
return $this->canRender;
}
}
+ // Thumbnailing a very large file could result in network saturation if
+ // everyone does it at once.
+ if ( $this->getSize() >= 1e7 ) { // 10MB
+ $that = $this;
+ $work = new PoolCounterWorkViaCallback( 'GetLocalFileCopy', sha1( $this->getName() ),
+ array(
+ 'doWork' => function() use ( $that ) {
+ return $that->getLocalRefPath();
+ }
+ )
+ );
+ $srcPath = $work->execute();
+ } else {
+ $srcPath = $this->getLocalRefPath();
+ }
+
// Original file
return array(
- 'path' => $this->getLocalRefPath(),
+ 'path' => $srcPath,
'width' => $this->getWidth(),
'height' => $this->getHeight()
);
/**
* Creates a temp FS file with the same extension and the thumbnail
* @param string $thumbPath Thumbnail path
- * @returns TempFSFile
+ * @return TempFSFile
*/
protected function makeTransformTmpFile( $thumbPath ) {
$thumbExt = FileBackend::extensionFromPath( $thumbPath );
* @return ThumbnailImage
*/
function iconThumb() {
- global $wgStylePath, $wgStyleDirectory;
+ global $wgResourceBasePath, $IP;
+ $assetsPath = "$wgResourceBasePath/resources/assets/file-type-icons/";
+ $assetsDirectory = "$IP/resources/assets/file-type-icons/";
$try = array( 'fileicon-' . $this->getExtension() . '.png', 'fileicon.png' );
foreach ( $try as $icon ) {
- $path = '/common/images/icons/' . $icon;
- $filepath = $wgStyleDirectory . $path;
- if ( file_exists( $filepath ) ) { // always FS
+ if ( file_exists( $assetsDirectory . $icon ) ) { // always FS
$params = array( 'width' => 120, 'height' => 120 );
- return new ThumbnailImage( $this, $wgStylePath . $path, false, $params );
+ return new ThumbnailImage( $this, $assetsPath . $icon, false, $params );
}
}
/**
* Get last thumbnailing error.
* Largely obsolete.
+ * @return string
*/
function getLastError() {
return $this->lastError;