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





