lonelyplanet / append-file-hash
Append a file hash to file names for media library uploads.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 141
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Type:wordpress-plugin
Requires
- php: >=5.3
- composer/installers: ^1.0
This package is auto-updated.
Last update: 2022-05-11 09:36:52 UTC
README
This WordPress plugin will append a file hash to file names for media library uploads.
Installation
composer require lonelyplanet/append-file-hash
Filters
Customize the file hash
By default, this plugin will use the md5_file hash and append it to the filename.
If you'd like to customize the hash, you can use the afh-file-hash
filter.
In this example, the sha1 file hash is returned.
function sha1FileHash($hash, $data, $filepath, $filename, $mimes) { return sha1_file($filepath); } add_filter('afh-file-hash', 'sha1FileHash', 10, 5);
Customize the proper filename
function customProperFilename($properFilename, $cleanFilename, $hash, $ext, $filepath, $mimes) { // Build your filename here. return $properFilename; } add_filter('afh-proper-filename', 'customProperFilename', 10, 6);