GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing www.mediawiki.org — Manual:$wgForeignFileRepos - MediaWiki
Details
Properties required for all repos
For all core repos
ForeignAPIRepo class
ForeignDBRepo class
Default value (code in includes/SetupDynamicConfig.php): if ( $wgUseSharedUploads ) { if ( $wgSharedUploadDBname ) { $wgForeignFileRepos[] = [ 'class' => ForeignDBRepo::class, 'name' => 'shared', 'directory' => $wgSharedUploadDirectory, 'url' => $wgSharedUploadPath, 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0, 'thumbScriptUrl' => $wgSharedThumbnailScriptPath, 'transformVia404' => !$wgGenerateThumbnailOnParse, 'dbType' => $wgDBtype, 'dbServer' => $wgDBserver, 'dbUser' => $wgDBuser, 'dbPassword' => $wgDBpassword, 'dbName' => $wgSharedUploadDBname, 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT, 'tablePrefix' => $wgSharedUploadDBprefix, 'hasSharedCache' => $wgCacheSharedUploads, 'descBaseUrl' => $wgRepositoryBaseUrl, 'fetchDescription' => $wgFetchCommonsDescriptions, ]; } else { $wgForeignFileRepos[] = [ 'class' => FileRepo::class, 'name' => 'shared', 'directory' => $wgSharedUploadDirectory, 'url' => $wgSharedUploadPath, 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0, 'thumbScriptUrl' => $wgSharedThumbnailScriptPath, 'transformVia404' => !$wgGenerateThumbnailOnParse, 'descBaseUrl' => $wgRepositoryBaseUrl, 'fetchDescription' => $wgFetchCommonsDescriptions, ]; } } ForeignDBViaLBRepo class
Directory permissionsYou'll need rw on Usage
Using files from Wikimedia Commons : ForeignAPIRepoSince 1.16.0 there is a more convenient shorthand to use Commons as a foreign repository:
$wgUseInstantCommons .If your wiki is throttled by Wikimedia Commons, please update to MediaWiki 1.45.0 (or MediaWiki 1.39.14+, 1.43.4+, or 1.44.1+) to comply with the User-Agent Policy.
You can set your wiki to use media from Wikimedia Commons (or from any other MediaWiki-powered site, see below) directly. However, please beware any legal implications. The code below enables media files from Wikimedia Commons on your site. You should place it in your $wgForeignFileRepos[] = [ 'class' => ForeignAPIRepo::class, 'name' => 'commonswiki', // Must be a distinct name 'apibase' => 'https://commons.wikimedia.org/w/api.php', 'hashLevels' => 2, 'fetchDescription' => true, // Optional 'descriptionCacheExpiry' => 43200, // 12 hours, optional (values are seconds) 'apiMetadataExpiry' => 14400, // 4 hours, optional. Consider increasing for better performance. 'apiThumbCacheExpiry' => 86400, // 24 hours, optional, but required for local thumb caching (Note local thumb caching is often slower than not doing it) ]; If you decide to add this setting to your
LocalSettings.php file instead of using $wgUseInstantCommons you cannot use wikimediacommons as a setting for name since it is already present in core MediaWiki code (in Setup.php).To pull images from another Wikimedia project, set $wgForeignFileRepos[] = [ 'class' => ForeignAPIRepo::class, 'name' => 'enwikipedia', 'apibase' => 'https://en.wikipedia.org/w/api.php', 'hashLevels' => 2, 'fetchDescription' => true, 'descriptionCacheExpiry' => 43200, 'apiThumbCacheExpiry' => 86400, ]; To embed an image in your installation, simply use PerformanceYou may need to configure the Setting Currently MediaWiki does not support pipelining foreign api requests. A high performance site may want to look at setting up a local proxy (like nginx) that can coalesce multiple requests into a single pipelined request to reduce round trip times from TCP & TLS handshakes. There is also an alternative implementation at Extension:QuickInstantCommons which may be much faster Using files from a database that you can access : ForeignDBRepo, ForeignDBViaLBRepoThe ForeignDBRepo class is very useful for creating wiki families. In a wiki family, each wiki will have its own database or table prefix.
Using this class, you can make a family member aware of the tables of another family member.
Access through $wgForeignFileRepos[] = [ 'class' => ForeignDBRepo::class, 'name' => 'otherwiki', 'url' => "https://example.org/w/images", 'directory' => '/path/to/uploads', 'hashLevels' => 2, // This must be the same for the other family member 'dbType' => $wgDBtype, 'dbServer' => $wgDBserver, 'dbUser' => $wgDBuser, 'dbPassword' => $wgDBpassword, 'dbFlags' => DBO_DEFAULT, 'dbName' => 'mydb', 'tablePrefix' => 'mw_', 'hasSharedCache' => false, 'descBaseUrl' => 'https://example.org/wiki/File:', 'fetchDescription' => false ]; Alternatively, if you have $wgForeignFileRepos[] = [ 'class' => ForeignDBViaLBRepo::class, 'wiki' => 'wiki-db-name-used-with-wgLBFactoryConf', 'name' => 'otherwiki', # displayname (eg. the vector-skin-tab “View on OtherWiki“) may be set at wiki-specific MediaWiki:Shared-repo-name-<otherwiki> 'url' => 'https://example.org/w/images', 'directory' => '/path/to/uploads', 'hashLevels' => 2, # This must be the same for the other family member 'tablePrefix' => 'mw_', 'hasSharedCache' => false, 'fetchDescription' => true, 'scriptDirUrl' => 'https://example.org/w', # has effect whether description can be fetched ]; This needs not all the db* parameters as in Using files from a local folder : FileRepoYou can set your wiki to use media from a single folder. This is just a demonstration feature at present, and will probably be too slow for busy wikis or slow servers due to the lack of caching. This code should be added to The below code enabled media files from it: $wgForeignFileRepos[] = [ 'class' => FileRepo::class, 'name' => 'sharedFsRepo', 'directory' => 'media', 'hashLevels' => 0, 'url' => 'https://shared.example.org/path/to/media', ]; CaveatsFor optimal performance, use a wiki whose primary purpose is to serve as a commons as the target of Likewise, avoid sharing a database between the commons wiki and other content wikis, especially if you must use See also
| ||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | ||||||||||||||||||||