[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Contains the post embed content template part 4 * 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. 7 * 8 * @package WordPress 9 * @subpackage Theme_Compat 10 * @since 4.5.0 11 */ 12 ?> 13 <div <?php post_class( 'wp-embed' ); ?>> 14 <?php 15 $thumbnail_id = 0; 16 17 if ( has_post_thumbnail() ) { 18 $thumbnail_id = get_post_thumbnail_id(); 19 } 20 21 if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) { 22 $thumbnail_id = get_the_ID(); 23 } 24 25 /** 26 * Filters the thumbnail image ID for use in the embed template. 27 * 28 * @since 4.9.0 29 * 30 * @param int|false $thumbnail_id Attachment ID, or false if there is none. 31 */ 32 $thumbnail_id = apply_filters( 'embed_thumbnail_id', $thumbnail_id ); 33 34 if ( $thumbnail_id ) { 35 $aspect_ratio = 1; 36 $measurements = array( 1, 1 ); 37 $image_size = 'full'; // Fallback. 38 39 $meta = wp_get_attachment_metadata( $thumbnail_id ); 40 if ( ! empty( $meta['sizes'] ) ) { 41 foreach ( $meta['sizes'] as $size => $data ) { 42 if ( $data['height'] > 0 && $data['width'] / $data['height'] > $aspect_ratio ) { 43 $aspect_ratio = $data['width'] / $data['height']; 44 $measurements = array( $data['width'], $data['height'] ); 45 $image_size = $size; 46 } 47 } 48 } 49 50 /** 51 * Filters the thumbnail image size for use in the embed template. 52 * 53 * @since 4.4.0 54 * @since 4.5.0 Added `$thumbnail_id` parameter. 55 * 56 * @param string $image_size Thumbnail image size. 57 * @param int $thumbnail_id Attachment ID. 58 */ 59 $image_size = apply_filters( 'embed_thumbnail_image_size', $image_size, $thumbnail_id ); 60 61 $shape = $measurements[0] / $measurements[1] >= 1.75 ? 'rectangular' : 'square'; 62 63 /** 64 * Filters the thumbnail shape for use in the embed template. 65 * 66 * Rectangular images are shown above the title while square images 67 * are shown next to the content. 68 * 69 * @since 4.4.0 70 * @since 4.5.0 Added `$thumbnail_id` parameter. 71 * 72 * @param string $shape Thumbnail image shape. Either 'rectangular' or 'square'. 73 * @param int $thumbnail_id Attachment ID. 74 */ 75 $shape = apply_filters( 'embed_thumbnail_image_shape', $shape, $thumbnail_id ); 76 } 77 78 if ( $thumbnail_id && 'rectangular' === $shape ) : 79 ?> 80 <div class="wp-embed-featured-image rectangular"> 81 <a href="<?php the_permalink(); ?>" target="_top"> 82 <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?> 83 </a> 84 </div> 85 <?php endif; ?> 86 87 <p class="wp-embed-heading"> 88 <a href="<?php the_permalink(); ?>" target="_top"> 89 <?php the_title(); ?> 90 </a> 91 </p> 92 93 <?php if ( $thumbnail_id && 'square' === $shape ) : ?> 94 <div class="wp-embed-featured-image square"> 95 <a href="<?php the_permalink(); ?>" target="_top"> 96 <?php echo wp_get_attachment_image( $thumbnail_id, $image_size ); ?> 97 </a> 98 </div> 99 <?php endif; ?> 100 101 <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div> 102 103 <?php 104 /** 105 * Prints additional content after the embed excerpt. 106 * 107 * @since 4.4.0 108 */ 109 do_action( 'embed_content' ); 110 ?> 111 112 <div class="wp-embed-footer"> 113 <?php the_embed_site_title(); ?> 114 115 <div class="wp-embed-meta"> 116 <?php 117 /** 118 * Prints additional meta content in the embed template. 119 * 120 * @since 4.4.0 121 */ 122 do_action( 'embed_content_meta' ); 123 ?> 124 </div> 125 </div> 126 </div> 127 <?php
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 25 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |