From 178239e07c3cb2769a2179467e2394798665de46 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 16 Jul 2009 18:07:23 +0000 Subject: [PATCH] * Added FSRepo configuration properties thumbUrl and thumbDir, to allow the thumbnails to be stored in a separate location to the source images. Did this by making thumbnails a separate zone instead of a subdirectory of the public zone. Tested normal transform, thumb.php. * Removed getThumbRel(), doesn't make sense in conjunction with above options. Not used by core or hosted extensions. --- RELEASE-NOTES | 2 ++ includes/DefaultSettings.php | 7 ++++++- includes/filerepo/FSRepo.php | 14 ++++++++++++++ includes/filerepo/File.php | 19 +++++++------------ 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 703de6d269..dbf327287b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -143,6 +143,8 @@ this. Was used when mwEmbed was going to be an extension. display for old versions of images. * In watchlists and Special:RecentChanges, the difference in page size now appears in dark green if bytes were added and dark red if bytes were removed. +* Added FSRepo configuration properties thumbUrl and thumbDir, to allow the + thumbnails to be stored in a separate location to the source images. === Bug fixes in 1.16 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d84fd598d5..23841300f0 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -204,7 +204,7 @@ $wgFileStore['deleted']['hash'] = 3; ///< 3-level subdirectory split * * name A unique name for the repository. * - * For all core repos: + * For most core repos: * url Base public URL * hashLevels The number of directory levels for hash-based division of files * thumbScriptUrl The URL for thumb.php (optional, not recommended) @@ -220,6 +220,11 @@ $wgFileStore['deleted']['hash'] = 3; ///< 3-level subdirectory split * placeholders. Default for LocalRepo is 'simple'. * fileMode This allows wikis to set the file mode when uploading/moving files. Default * is 0644. + * directory The local filesystem directory where public files are stored. Not used for + * some remote repos. + * thumbDir The base thumbnail directory. Defaults to /thumb. + * thumbUrl The base thumbnail URL. Defaults to /thumb. + * * * These settings describe a foreign MediaWiki installation. They are optional, and will be ignored * for local repositories: diff --git a/includes/filerepo/FSRepo.php b/includes/filerepo/FSRepo.php index 680ec93d7c..5bc6034e3b 100644 --- a/includes/filerepo/FSRepo.php +++ b/includes/filerepo/FSRepo.php @@ -24,6 +24,16 @@ class FSRepo extends FileRepo { $info['deletedHashLevels'] : $this->hashLevels; $this->deletedDir = isset( $info['deletedDir'] ) ? $info['deletedDir'] : false; $this->fileMode = isset( $info['fileMode'] ) ? $info['fileMode'] : 0644; + if ( isset( $info['thumbDir'] ) ) { + $this->thumbDir = $info['thumbDir']; + } else { + $this->thumbDir = "{$this->directory}/thumb"; + } + if ( isset( $info['thumbUrl'] ) ) { + $this->thumbUrl = $info['thumbUrl']; + } else { + $this->thumbUrl = "{$this->url}/thumb"; + } } /** @@ -58,6 +68,8 @@ class FSRepo extends FileRepo { return "{$this->directory}/temp"; case 'deleted': return $this->deletedDir; + case 'thumb': + return $this->thumbDir; default: return false; } @@ -74,6 +86,8 @@ class FSRepo extends FileRepo { return "{$this->url}/temp"; case 'deleted': return false; // no public URL + case 'thumb': + return $this->thumbUrl; default: return false; } diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index 594aae2f1d..c790b3be16 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -746,15 +746,6 @@ abstract class File { return $path; } - /** Get relative path for a thumbnail file */ - function getThumbRel( $suffix = false ) { - $path = 'thumb/' . $this->getRel(); - if ( $suffix !== false ) { - $path .= '/' . $suffix; - } - return $path; - } - /** Get the path of the archive directory, or a particular file if $suffix is specified */ function getArchivePath( $suffix = false ) { return $this->repo->getZonePath('public') . '/' . $this->getArchiveRel( $suffix ); @@ -762,7 +753,11 @@ abstract class File { /** Get the path of the thumbnail directory, or a particular file if $suffix is specified */ function getThumbPath( $suffix = false ) { - return $this->repo->getZonePath('public') . '/' . $this->getThumbRel( $suffix ); + $path = $this->repo->getZonePath('thumb') . '/' . $this->getRel(); + if ( $suffix !== false ) { + $path .= '/' . $suffix; + } + return $path; } /** Get the URL of the archive directory, or a particular file if $suffix is specified */ @@ -778,7 +773,7 @@ abstract class File { /** Get the URL of the thumbnail directory, or a particular file if $suffix is specified */ function getThumbUrl( $suffix = false ) { - $path = $this->repo->getZoneUrl('public') . '/thumb/' . $this->getUrlRel(); + $path = $this->repo->getZoneUrl('thumb') . '/' . $this->getUrlRel(); if ( $suffix !== false ) { $path .= '/' . rawurlencode( $suffix ); } @@ -798,7 +793,7 @@ abstract class File { /** Get the virtual URL for a thumbnail file or directory */ function getThumbVirtualUrl( $suffix = false ) { - $path = $this->repo->getVirtualUrl() . '/public/thumb/' . $this->getUrlRel(); + $path = $this->repo->getVirtualUrl() . '/thumb/' . $this->getUrlRel(); if ( $suffix !== false ) { $path .= '/' . rawurlencode( $suffix ); } -- 2.20.1