Reputation: 1133
I'm looking for a configuration option, extension, or tool for Mediawiki that allows automatic renaming of uploaded files.
In short, whenever you upload a file, its name on the server (after upload) will be F(filename) for some function F. This function would preferably be configurable from the regular wiki UI although a hardcoded (or config) PHP back-end function would also be acceptable for this purpose.
The automatic rename could be implemented as a suggestion or default destination filename. For example, in an extension that modifies Special:Upload, it could autopopulate the Destination Filename field with F(filename).
I searched for extensions that do this and everything appears to be manual rename.
Upvotes: 0
Views: 135
Reputation: 28210
Pywikibot can rename files. For new uploads, you can probably use the UploadForm:BeforeProcessing hook (this will only affect uploads via Special:Upload though, not e.g. uploads via the API):
array_unshift( $wgHooks['UploadForm:BeforeProcessing'], function ( SpecialUpload $uploadFormObj ) {
$uploadFormObj->mDesiredDestName = F( $uploadFormObj->mDesiredDestName );
} );
Upvotes: 0