wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
_wp_post_thumbnail_html › WordPress Function
Seit2.9.0
Veraltetn/v
› _wp_post_thumbnail_html ( $thumbnail_id = null, $post = null )
Parameter: (2) |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Returns HTML for the post thumbnail meta box.
Ähnliche Funktionen: wp_ajax_get_post_thumbnail_html, the_post_thumbnail_url, the_post_thumbnail, set_post_thumbnail, has_post_thumbnail
Quellcode
function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { $_wp_additional_image_sizes = wp_get_additional_image_sizes(); $post = get_post( $post ); $post_type_object = get_post_type_object( $post->post_type ); $set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox">%s</a></p>'; $upload_iframe_src = get_upload_iframe_src( 'image', $post->ID ); $content = sprintf( $set_thumbnail_link, esc_url( $upload_iframe_src ), '', // Empty when there's no featured image set, `aria-describedby` attribute otherwise. esc_html( $post_type_object->labels->set_featured_image ) ); if ( $thumbnail_id && get_post( $thumbnail_id ) ) { $size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 ); /** * Filters the size used to display the post thumbnail image in the 'Featured image' meta box. * * Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail' * image size is registered, which differs from the 'thumbnail' image size * managed via the Settings > Media screen. * * @since 4.4.0 * * @param string|int[] $size Requested image size. Can be any registered image size name, or * an array of width and height values in pixels (in that order). * @param int $thumbnail_id Post thumbnail attachment ID. * @param WP_Post $post The post object associated with the thumbnail. */ $size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post ); $thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size ); if ( ! empty( $thumbnail_html ) ) { $content = sprintf( $set_thumbnail_link, esc_url( $upload_iframe_src ), ' aria-describedby="set-post-thumbnail-desc"', $thumbnail_html ); $content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __( 'Click the image to edit or update' ) . '</p>'; $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>'; } } $content .= '<input type="hidden" id="_thumbnail_id" name="_thumbnail_id" value="' . esc_attr( $thumbnail_id ? $thumbnail_id : '-1' ) . '" />'; /** * Filters the admin post thumbnail HTML markup to return. * * @since 2.9.0 * @since 3.5.0 Added the `$post_id` parameter. * @since 4.6.0 Added the `$thumbnail_id` parameter. * * @param string $content Admin post thumbnail HTML markup. * @param int $post_id Post ID. * @param int|null $thumbnail_id Thumbnail attachment ID, or null if there isn't one. */ return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id ); }