钩子文档

embed_thumbnail_image_shape

💡 云策文档标注

概述

embed_thumbnail_image_shape 是一个 WordPress 过滤器,用于控制嵌入模板中缩略图的形状显示方式。它允许开发者根据缩略图是矩形还是方形来调整布局,例如矩形图显示在标题上方,方形图显示在内容旁边。

关键要点

  • 过滤器名称:embed_thumbnail_image_shape
  • 参数:$shape(字符串,可选 'rectangular' 或 'square')和 $thumbnail_id(整数,附件 ID)
  • 用途:修改嵌入模板中缩略图的形状,影响显示位置(矩形图在标题上,方形图在内容旁)
  • 版本历史:在 WordPress 4.4.0 引入,4.5.0 添加了 $thumbnail_id 参数

代码示例

$shape = apply_filters( 'embed_thumbnail_image_shape', $shape, $thumbnail_id );

📄 原文内容

Filters the thumbnail shape for use in the embed template.

Description

Rectangular images are shown above the title while square images are shown next to the content.

Parameters

$shapestring
Thumbnail image shape. Either 'rectangular' or 'square'.
$thumbnail_idint
Attachment ID.

Source

$shape = apply_filters( 'embed_thumbnail_image_shape', $shape, $thumbnail_id );

Changelog

Version Description
4.5.0 Added $thumbnail_id parameter.
4.4.0 Introduced.