PATH:
home
/
sarkas88.com
/
public_html
/
wp-includes
/
blocks
<?php /** * Server-side rendering of the `core/video` block. * * @package WordPress */ /** * Renders the `core/video` block on the server to supply the width and height attributes from the attachment metadata. * * @since 6.9.0 * * @phpstan-param array{ "id"?: positive-int } $attributes * * @param array $attributes The block attributes. * @param string $content The block content. * @return string The block content with the dimensions added. */ function render_block_core_video( array $attributes, string $content ): string { // if the content lacks any video tag, abort. if ( ! str_contains( $content, '<video' ) ) { return $content; } // If the 'id' attribute is not populated for a video attachment, abort. if ( ! isset( $attributes['id'] ) || ! is_int( $attributes['id'] ) || $attributes['id'] <= 0 ) { return $content; } // If the 'id' attribute wasn't for an attachment, abort. if ( get_post_type( $attributes['id'] ) !== 'attachment' ) { return $content; } // Get the width and height metadata for the video, and abort if absent or invalid. $metadata = wp_get_attachment_metadata( $attributes['id'] ); if ( ! isset( $metadata['width'], $metadata['height'] ) || ! ( is_int( $metadata['width'] ) && is_int( $metadata['height'] ) ) || ! ( $metadata['width'] > 0 && $metadata['height'] > 0 ) ) { return $content; } // Locate the VIDEO tag to add the dimensions. $p = new WP_HTML_Tag_Processor( $content ); if ( ! $p->next_tag( array( 'tag_name' => 'VIDEO' ) ) ) { return $content; } $p->set_attribute( 'width', (string) $metadata['width'] ); $p->set_attribute( 'height', (string) $metadata['height'] ); /* * The aspect-ratio style is needed due to an issue with the CSS spec: <https://github.com/w3c/csswg-drafts/issues/7524>. * Note that a style rule using attr() like the following cannot currently be used: * * .wp-block-video video[width][height] { * aspect-ratio: attr(width type(<number>)) / attr(height type(<number>)); * } * * This is because this attr() is yet only implemented in Chromium: <https://caniuse.com/css3-attr>. */ $style = $p->get_attribute( 'style' ); if ( ! is_string( $style ) ) { $style = ''; } $aspect_ratio_style = sprintf( 'aspect-ratio: %d / %d;', $metadata['width'], $metadata['height'] ); $p->set_attribute( 'style', $aspect_ratio_style . $style ); return $p->get_updated_html(); } /** * Registers the `core/video` block on server. * * @since 6.9.0 */ function register_block_core_video(): void { register_block_type_from_metadata( __DIR__ . '/video', array( 'render_callback' => 'render_block_core_video', ) ); } add_action( 'init', 'register_block_core_video' );
[+]
..
[-] query-no-results.php
[open]
[-] calendar.php
[open]
[-] comments-pagination-numbers.php
[open]
[+]
paragraph
[+]
post-comments-count
[-] site-title.php
[open]
[+]
widget-group
[-] page-list-item.php
[open]
[+]
site-logo
[-] post-content.php
[open]
[+]
tag-cloud
[+]
categories
[+]
text-columns
[-] legacy-widget.php
[open]
[-] query-pagination-numbers.php
[open]
[-] image.php
[open]
[+]
more
[+]
spacer
[-] list.php
[open]
[+]
post-date
[-] post-comments-link.php
[open]
[+]
page-list-item
[+]
post-author-name
[+]
heading
[-] comments-pagination.php
[open]
[-] gallery.php
[open]
[-] accordion.php
[open]
[-] latest-comments.php
[open]
[+]
loginout
[-] home-link.php
[open]
[+]
query-no-results
[+]
site-title
[+]
math
[+]
post-title
[+]
read-more
[+]
latest-posts
[-] read-more.php
[open]
[-] post-comments-form.php
[open]
[-] page-list.php
[open]
[+]
table
[+]
comments-title
[+]
post-author
[+]
home-link
[+]
comment-author-name
[+]
post-terms
[+]
freeform
[+]
query-pagination-previous
[-] post-date.php
[open]
[+]
post-comments-link
[+]
comment-reply-link
[+]
columns
[+]
post-time-to-read
[+]
post-content
[-] comment-template.php
[open]
[+]
comments-pagination-previous
[-] pattern.php
[open]
[-] accordion-item.php
[open]
[-] site-logo.php
[open]
[-] comments-pagination-previous.php
[open]
[+]
details
[-] archives.php
[open]
[+]
terms-query
[+]
block
[-] widget-group.php
[open]
[+]
accordion-panel
[+]
list-item
[-] post-author.php
[open]
[-] term-name.php
[open]
[-] heading.php
[open]
[-] query-title.php
[open]
[-] latest-posts.php
[open]
[+]
latest-comments
[+]
nextpage
[-] search.php
[open]
[-] blocks-json.php
[open]
[+]
pattern
[-] query-pagination-next.php
[open]
[+]
pullquote
[-] site-tagline.php
[open]
[+]
gallery
[+]
code
[-] post-author-biography.php
[open]
[+]
list
[+]
file
[+]
post-comments-form
[-] navigation-submenu.php
[open]
[-] file.php
[open]
[+]
button
[+]
media-text
[+]
accordion
[-] button.php
[open]
[+]
term-template
[+]
preformatted
[+]
query-total
[+]
accordion-item
[-] index.php
[open]
[+]
legacy-widget
[-] media-text.php
[open]
[+]
image
[-] term-description.php
[open]
[+]
post-excerpt
[-] navigation.php
[open]
[+]
audio
[-] comment-content.php
[open]
[+]
quote
[-] tag-cloud.php
[open]
[-] query.php
[open]
[+]
post-author-biography
[-] avatar.php
[open]
[-] post-featured-image.php
[open]
[+]
comments
[+]
missing
[+]
query
[-] categories.php
[open]
[+]
shortcode
[+]
verse
[+]
comments-pagination-numbers
[-] social-link.php
[open]
[-] comment-date.php
[open]
[+]
social-link
[-] comments.php
[open]
[-] require-dynamic-blocks.php
[open]
[-] post-template.php
[open]
[+]
rss
[+]
comments-pagination-next
[-] comments-pagination-next.php
[open]
[+]
accordion-heading
[-] video.php
[open]
[+]
archives
[-] footnotes.php
[open]
[+]
post-navigation-link
[+]
html
[+]
comment-date
[-] block.php
[open]
[-] require-static-blocks.php
[open]
[+]
social-links
[+]
query-pagination-next
[-] term-template.php
[open]
[-] post-author-name.php
[open]
[+]
comment-edit-link
[+]
video
[-] navigation-link.php
[open]
[+]
term-count
[+]
query-pagination
[-] comment-edit-link.php
[open]
[+]
navigation-submenu
[-] post-title.php
[open]
[-] post-terms.php
[open]
[+]
column
[+]
post-featured-image
[-] template-part.php
[open]
[+]
navigation-link
[+]
comments-pagination
[-] post-time-to-read.php
[open]
[-] cover.php
[open]
[+]
query-pagination-numbers
[+]
embed
[+]
footnotes
[-] rss.php
[open]
[+]
comment-content
[+]
separator
[+]
cover
[-] comments-title.php
[open]
[+]
page-list
[+]
template-part
[-] comment-author-name.php
[open]
[-] term-count.php
[open]
[+]
term-name
[-] loginout.php
[open]
[+]
query-title
[-] post-navigation-link.php
[open]
[-] post-comments-count.php
[open]
[+]
site-tagline
[+]
navigation
[-] query-total.php
[open]
[+]
term-description
[+]
post-template
[-] post-excerpt.php
[open]
[-] query-pagination-previous.php
[open]
[+]
buttons
[+]
avatar
[+]
calendar
[-] query-pagination.php
[open]
[+]
group
[-] comment-reply-link.php
[open]
[-] shortcode.php
[open]
[+]
search
[+]
comment-template