how to get YouTube video id from image thumbnail source, and set as an iframe?

前端 未结 3 450
情歌与酒
情歌与酒 2020-12-22 08:58

So if the image tag is


I don\'t know how to e

3条回答
  •  被撕碎了的回忆
    2020-12-22 09:36

    This extracts the YouTube ID using a Regular Expression, I made the assumption that it would be a minimum of eleven characters as the first YouTube Video ID has 11.

    
    
    
    
    

    This works, however the YouTube Player API may provide you with a more stable solution to loading that iFrame, in the future once it becomes stable I would recommend the YouTube iFrame API

提交回复
热议问题