wp_mail_embed_args
云策文档标注
概述
wp_mail_embed_args 是一个 WordPress 过滤器,用于修改 PHPMailer 的 addEmbeddedImage() 方法的参数数组。它允许开发者在嵌入邮件图片时自定义路径、CID、名称、编码、类型和处置方式等属性。
关键要点
- 过滤器名称:wp_mail_embed_args
- 作用:过滤 addEmbeddedImage() 方法的参数数组
- 参数数组包括:path(文件路径)、cid(Content-ID,默认为 embeds 数组的键)、name(文件名)、encoding(编码,默认为 'base64')、type(MIME 类型,默认为空字符串以自动检测)、disposition(处置方式,默认为 'inline')
- 引入版本:WordPress 6.9.0
代码示例
$embed_args = apply_filters(
'wp_mail_embed_args',
array(
'path' => $embed_path,
'cid' => (string) $key,
'name' => basename( $embed_path ),
'encoding' => 'base64',
'type' => '',
'disposition' => 'inline',
)
);
原文内容
Filters the arguments for PHPMailer’s addEmbeddedImage() method.
Parameters
$argsarray-
An array of arguments for
addEmbeddedImage().pathstringThe path to the file.cidstringThe Content-ID of the image. Default: The key in the embeds array.namestringThe filename of the image.encodingstringThe encoding of the image. Default:'base64'.typestringThe MIME type of the image. Default: empty string, which lets PHPMailer auto-detect.dispositionstringThe disposition of the image. Default:'inline'.
Source
$embed_args = apply_filters(
'wp_mail_embed_args',
array(
'path' => $embed_path,
'cid' => (string) $key,
'name' => basename( $embed_path ),
'encoding' => 'base64',
'type' => '',
'disposition' => 'inline',
)
);
Changelog
| Version | Description |
|---|---|
| 6.9.0 | Introduced. |