钩子文档

media_upload_{$type}

💡 云策文档标注

概述

此 Hook 在旧版(3.5.0 之前)媒体弹出窗口中,基于当前标签触发特定上传类型视图。动态部分 $type 指代具体媒体上传类型。

关键要点

  • Hook 名称动态部分为 $type,对应特定媒体上传类型,如 audio、file、image、video。
  • 仅当当前 $tab 为 'type'(从计算机上传)、'type_url'(从 URL 上传)或标签未注册时触发。
  • 通过 do_action( "media_upload_{$type}" ) 调用,用于自定义媒体上传界面。

注意事项

  • 此 Hook 仅适用于 WordPress 3.5.0 之前的旧版媒体弹出窗口,新版可能已弃用或更改。
  • 使用前需检查当前标签状态,确保符合触发条件。

📄 原文内容

Fires inside specific upload-type views in the legacy (pre-3.5.0) media popup based on the current tab.

Description

The dynamic portion of the hook name, $type, refers to the specific media upload type.

The hook only fires if the current $tab is ‘type’ (From Computer), ‘type_url’ (From URL), or, if the tab does not exist (i.e., has not been registered via the ‘media_upload_tabs’ filter.

Possible hook names include:

  • media_upload_audio
  • media_upload_file
  • media_upload_image
  • media_upload_video

Source

do_action( "media_upload_{$type}" );

Changelog

Version Description
2.5.0 Introduced.