lonelyplanet/append-file-hash

为媒体库上传添加文件哈希到文件名。

此包的官方仓库似乎已消失,因此包已被冻结。

安装: 141

依赖关系: 0

建议者: 0

安全: 0

星标: 0

关注者: 4

分支: 0

开放问题: 0

类型:wordpress-plugin

1.0.2 2018-01-31 20:45 UTC

This package is auto-updated.

Last update: 2022-05-11 09:36:52 UTC


README

此WordPress插件将为媒体库上传的文件名添加文件哈希。

安装

composer require lonelyplanet/append-file-hash

过滤器

自定义文件哈希

默认情况下,此插件将使用 md5_file 哈希并将其附加到文件名。如果您想自定义哈希,可以使用 afh-file-hash 过滤器。

在这个例子中,返回了sha1文件哈希。

function sha1FileHash($hash, $data, $filepath, $filename, $mimes)
{
    return sha1_file($filepath);
}

add_filter('afh-file-hash', 'sha1FileHash', 10, 5);

自定义正确的文件名

function customProperFilename($properFilename, $cleanFilename, $hash, $ext, $filepath, $mimes)
{
    // Build your filename here.

    return $properFilename;
}

add_filter('afh-proper-filename', 'customProperFilename', 10, 6);