如何給WordPress網站插入視頻呢?我們一起看看插入視頻短代碼WordPress函數wp_video_shortcode。
wp_video_shortcode( array $attr, string $content = '' )
wp_video_shortcode的官方描述,用來構建短代碼輸出視頻。這實現了視頻短代碼在帖子中顯示mp4的功能。
參數說明
$attr
(array) (必須) 短代碼屬性值
‘src’
(string) 視頻資源的URL地址,默認空
‘height’
(int) 嵌入視頻元素的高度值像素,默認360
‘width’
(int) 嵌入視頻元素的寬度值像素,默認$content_width 或 640.
‘poster’
(string) <video> 元素的post屬性值. 默認為空.
‘loop’
(string) <video> 元素loop屬性值,默認空
‘autoplay’
(string) <video> 元素的autoplay屬性值,默認空
‘preload’
(string) <video> 元素的’preload’屬性值,默認 ‘metadata’.
‘class’
(string) <video> 元素的’class’屬性值 默認 ‘wp-video-shortcode’.
$content
(string) (可選) 短代碼內容,默認空
返回值
<video>元素顯示的HTML內容
代碼位置
文件位于:wp-includes/media.php,在線地址:https://developer.wordpress.org/reference/files/wp-includes/media.php/





