Manual:Hooks/UploadComplete
Appearance
From mediawiki.org
This page is a translated version of the page Manual:Hooks/UploadComplete and the translation is 75% complete.
| UploadComplete | |
|---|---|
| Erhältlich ab Version 1.6.4 Called when a file upload has completed. | |
| Funktion definieren: | public static function onUploadComplete( $image ) { ... } |
| Haken anbringen: | In extension.json:
{ "Hooks":{ "UploadComplete":"MediaWiki\\Extension\\MyExtension\\Hooks::onUploadComplete" } } |
| Angerufen von: | Datei(en): Upload/UploadBase.php |
| Interface: | UploadCompleteHook.php |
For more information about attaching hooks, see Handbuch:Hooks .
For examples of extensions using this hook, see Category:UploadComplete extensions/de.
Details
- $image:
(削除) Die gespeicherte Datei (object) (削除ここまで)UploadForm object (since 1.16.0? UploadBase) - Zurückgegebener Wert: "True", falls andere Hooks ausgewertet werden sollen; "False", falls die Auswertung angehalten werden soll. Falls kein Wiedergabewert angegeben wird, tritt ein Fehler auf.
Beispielmethoden
If you want to know what methods an upload form object has, see includes/special/SpecialUpload.php.
Einige Beispiele:
$image->getLocalFile(); // LocalFile Object $image->getLocalFile()->fileExists; // 1 or 0 $image->getLocalFile()->media_type; // examples: "AUDIO", "VIDEO", ... $image->getLocalFile()->mime; // example: audio/mp3 $image->getLocalFile()->major_mime; // e.g. audio $image->getLocalFile()->minor_mime; // e.g. mp3 $image->getLocalFile()->size; //in bytes, e.g. 2412586 $image->getLocalFile()->user; // int userId $image->getLocalFile()->user_text; // the username $image->getLocalFile()->description; $image->getLocalFile()->url; // gives the relative url for direct access of the uploaded media $image->getLocalFile()->getTitle(); // gives a title object for the current media /** * Do existence checks on a file and produce a warning * This check is static and can be done pre-upload via AJAX * Returns an HTML fragment consisting of one or more LI elements if there is a warning * Returns an empty string if there is no warning */ static function getExistsWarning( $file ); /** * Split a file into a base name and all dot-delimited 'extensions' * on the end. Some web server configurations will fall back to * earlier pseudo-'extensions' to determine type and execute * scripts, so the blacklist needs to check them all. * * @return array */ function splitExtensions( $filename );