正在搜索Featured Image
我被引导到\\wp-admin\\edit-form-advanced.php
, 在那里,我发现一个添加了回调参数post_thumbnail_meta_box
.
然后我搜索了post_thumbnail_meta_box
, 最终在\\wp-admin\\includes\\meta-boxes.php
, 我们可以看到,WP通过以下方式获取帖子缩略图:
$thumbnail_id = get_post_meta( $post->ID, \'_thumbnail_id\', true );
然后用这个做一些魔术:
echo _wp_post_thumbnail_html( $thumbnail_id );
正在搜索
function _wp_post_thumbnail_html
引导我们
\\wp-admin\\includes\\post.php
, 我们看到WP决定了它想要使用的大小,但在最后一刻,我们有机会通过以下方式处理图像:
return apply_filters( \'admin_post_thumbnail_html\', $content );
示例:
function admin_post_thumbnail_kittenifier( $content ) {
// In reality, you might want to replicate some of the code from _wp_post_thumbnail_html(), but this gives you the idea
return "<img src=\'http://placekitten.com/200/300\' alt=\'I can has toxoplasma gondii?\'/>";
}
add_filter( \'admin_post_thumbnail_html\', \'admin_post_thumbnail_kittenifier\' );