load_image_to_edit_attachmenturl
云策文档标注
概述
load_image_to_edit_attachmenturl 是一个 WordPress 过滤器,用于在编辑图像时修改附件 URL 的路径。该过滤器仅在文件非本地存储且服务器启用 allow_url_fopen 时生效。
关键要点
- 过滤器名称:load_image_to_edit_attachmenturl
- 用途:过滤附件 URL 路径,适用于远程存储的图像编辑场景
- 触发条件:文件非本地存储且服务器 allow_url_fopen 启用
- 参数:$image_url(当前图像 URL,字符串或 false)、$attachment_id(附件 ID,整数)、$size(请求的图像尺寸,字符串或像素数组)
- 源代码位置:wp-admin/includes/image.php 中的 _load_image_to_edit_path() 函数
- 引入版本:3.1.0
原文内容
Filters the path to an attachment’s URL when editing the image.
Description
The filter is only evaluated if the file isn’t stored locally and allow_url_fopen is enabled on the server.
Parameters
$image_urlstring|false-
Current image URL.
$attachment_idint-
Attachment ID.
$sizestring|int[]-
Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
Source
$filepath = apply_filters( 'load_image_to_edit_attachmenturl', wp_get_attachment_url( $attachment_id ), $attachment_id, $size );
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |