钩子文档

wp_image_file_matches_image_meta

💡 云策文档标注

概述

wp_image_file_matches_image_meta 是一个 WordPress 过滤器,用于判断图像路径或 URI 是否与图像元数据匹配。它允许开发者自定义匹配逻辑,例如在图像处理或验证场景中。

关键要点

  • 过滤器名称:wp_image_file_matches_image_meta
  • 参数:$match(布尔值,表示是否匹配)、$image_location(字符串,图像文件的完整路径或 URI)、$image_meta(数组,图像元数据)、$attachment_id(整数,附件 ID 或 0)
  • 用途:在 wp_image_file_matches_image_meta() 函数中调用,用于确定图像源文件是否与元数据对应
  • 引入版本:WordPress 5.5.0

📄 原文内容

Filters whether an image path or URI matches image meta.

Parameters

$matchbool
Whether the image relative path from the image meta matches the end of the URI or path to the image file.
$image_locationstring
Full path or URI to the tested image file.
$image_metaarray
The image meta data as returned by ‘wp_get_attachment_metadata() ‘.
$attachment_idint
The image attachment ID or 0 if not supplied.

Source

return apply_filters( 'wp_image_file_matches_image_meta', $match, $image_location, $image_meta, $attachment_id );

Changelog

Version Description
5.5.0 Introduced.