3 * Contains the post embed content template part
5 * When a post is embedded in an iframe, this file is used to create the content template part
6 * output if the active theme does not include an embed-content.php template.
9 * @subpackage Theme_Compat
13 <div <?php post_class( 'wp-embed' ); ?>>
17 if ( has_post_thumbnail() ) {
18 $thumbnail_id = get_post_thumbnail_id();
21 if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) {
22 $thumbnail_id = get_the_ID();
26 $measurements = array( 1, 1 );
27 $image_size = 'full'; // Fallback.
29 $meta = wp_get_attachment_metadata( $thumbnail_id );
30 if ( is_array( $meta ) ) {
31 foreach ( $meta['sizes'] as $size => $data ) {
32 if ( $data['width'] / $data['height'] > $aspect_ratio ) {
33 $aspect_ratio = $data['width'] / $data['height'];
34 $measurements = array( $data['width'], $data['height'] );
41 * Filter the thumbnail image size for use in the embed template.
44 * @since 4.5.0 Added `$thumbnail_id` parameter.
46 * @param string $image_size Thumbnail image size.
47 * @param int $thumbnail_id Attachment ID.
49 $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size, $thumbnail_id );
51 $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square';
54 * Filter the thumbnail shape for use in the embed template.
56 * Rectangular images are shown above the title while square images
57 * are shown next to the content.
60 * @since 4.5.0 Added `$thumbnail_id` parameter.
62 * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'.
63 * @param int $thumbnail_id Attachment ID.
65 $shape = apply_filters( 'embed_thumbnail_image_shape', $shape, $thumbnail_id );
67 if ( 'rectangular' === $shape ) : ?>
68 <div class="wp-embed-featured-image rectangular">
69 <a href="<?php the_permalink(); ?>" target="_top">
70 <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?>
75 <p class="wp-embed-heading">
76 <a href="<?php the_permalink(); ?>" target="_top">
81 <?php if ( 'square' === $shape ) : ?>
82 <div class="wp-embed-featured-image square">
83 <a href="<?php the_permalink(); ?>" target="_top">
84 <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?>
89 <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div>
93 * Print additional content after the embed excerpt.
97 do_action( 'embed_content' );
100 <div class="wp-embed-footer">
101 <?php the_embed_site_title() ?>
103 <div class="wp-embed-meta">
106 * Print additional meta content in the embed template.
110 do_action( 'embed_content_meta');