Manual:Hooks/ResourceLoaderModifyEmbeddedSourceUrls
Appearance
| ResourceLoaderModifyEmbeddedSourceUrls | |
|---|---|
| Available from version 1.43.0 (Gerrit change 1076243) Allows modifying source URLs (i.e. URLs to load.php) before they get embedded in the JS generated for the startup module. | |
| Define function: | public static function onResourceLoaderModifyEmbeddedSourceUrls( array &$urls ) { ... }
|
| Attach hook: | In extension.json:
{
"Hooks": {
"ResourceLoaderModifyEmbeddedSourceUrls": "MediaWiki\\Extension\\MyExtension\\Hooks::onResourceLoaderModifyEmbeddedSourceUrls"
}
}
|
| Called from: | File(s): ResourceLoader/ImageModule.php, ResourceLoader/StartUpModule.php |
| Interface: | ResourceLoaderModifyEmbeddedSourceUrlsHook.php |
For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:ResourceLoaderModifyEmbeddedSourceUrls extensions.
Details
[edit]- array &$urls - An array of source name => URL; the URL might be relative.
Usage
[edit]The hook lets you modify ResourceLoader source URLs (i.e. URLs to load.php, see ResourceLoader::getSources) before they get embedded in the JS generated for the startup module.
The hook must not add or remove sources, and calling the new URL should have a roughly similar outcome to calling the old URL. It is mainly intended to preserve URL modifications that might affect the code generated for the modules (e.g. when load.php?modules=startup is called on the mobile site, it should generate source URLs which also use the mobile site).
See also
- ResourceLoader
$wgResourceModules- Register modules that can later be loaded on a page$wgResourceModuleSkinStyles- Register skin-provided stylesheets to add to an existing ResourceLoader module$wgResourceLoaderDebug- Configure the default debug mode for MediaWiki.- Internal configuration settings:
$wgExtensionAssetsPath,$wgResourceLoaderMaxage ResourceLoaderRegisterModuleshook- Developing with ResourceLoader – Learn how to use ResourceLoader in MediaWiki