/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/block-library/src/video/save.js
58 строк
1 KB
Marco Ciampini
ESLint: Replace strict config with bulk suppressions (#81248)
07 авг 2026, 14:34
Не верифицирован
07 авг 2026, 14:34
7f43eaf
Код
Авторство
О чём код?
import { RichText, useBlockProps, __experimentalGetElementClassName, } from '@wordpress/block-editor'; import Tracks from './tracks'; export default function save( { attributes } ) { const { autoplay, caption, controls, loop, muted, poster, preload, src, playsInline, tracks, width, height, } = attributes; // Match the editor: an explicit (non-`auto`) aspect ratio keeps the // converted GIF video from briefly blowing up to a runaway height while the // poster/metadata load, which would otherwise flash on the front end and // cause layout shift. The width/height attributes only yield // `aspect-ratio: auto W/H`, whose `auto` keyword is unreliable during load. const aspectRatio = width && height ? `${ width } / ${ height }` : undefined; return ( <figure { ...useBlockProps.save() }> { src && ( <video autoPlay={ autoplay } controls={ controls } loop={ loop } muted={ muted } poster={ poster } preload={ preload !== 'metadata' ? preload : undefined } src={ src } playsInline={ playsInline } width={ width } height={ height } style={ aspectRatio ? { aspectRatio } : undefined } > <Tracks tracks={ tracks } /> </video> ) } { ! RichText.isEmpty( caption ) && ( <RichText.Content className={ __experimentalGetElementClassName( 'caption' ) } tagName="figcaption" value={ caption } /> ) } </figure> ); }