钩子文档

attachment_thumbnail_args

💡 云策文档标注

概述

attachment_thumbnail_args 是一个 WordPress 过滤器钩子,用于在创建附件缩略图时过滤参数。它允许开发者修改缩略图生成的配置数组。

关键要点

  • 这是一个过滤器钩子,名称为 'attachment_thumbnail_args'。
  • 主要参数包括 $image_attachment(缩略图参数数组)、$metadata(当前附件元数据)和 $uploaded(新上传文件信息)。
  • 常用于 wp_generate_attachment_metadata() 函数中,以自定义图像子尺寸的生成过程。

代码示例

$image_attachment = apply_filters( 'attachment_thumbnail_args', $image_attachment, $metadata, $uploaded );

注意事项

  • 该钩子自 WordPress 3.9.0 版本引入。
  • 上传文件信息 $uploaded 是一个数组,包含 file、url 和 type 等键。

📄 原文内容

Filters the parameters for the attachment thumbnail creation.

Parameters

$image_attachmentarray
An array of parameters to create the thumbnail.
$metadataarray
Current attachment metadata.
$uploadedarray
Information about the newly-uploaded file.

  • file string
    Filename of the newly-uploaded file.
  • url string
    URL of the uploaded file.
  • type string
    File type.

Source

$image_attachment = apply_filters( 'attachment_thumbnail_args', $image_attachment, $metadata, $uploaded );

Changelog

Version Description
3.9.0 Introduced.