/0.jpg * http://img.youtube.com/vi//1.jpg * http://img.youtube.com/vi//2.jpg * http://img.youtube.com/vi//3.jpg * * http://img.youtube.com/vi//default.jpg * http://img.youtube.com/vi//mqdefault.jpg * http://img.youtube.com/vi//hqdefault.jpg * http://img.youtube.com/vi//sddefault.jpg * http://img.youtube.com/vi//maxresdefault.jpg */ if ('medium' === $format) { return 'https://img.youtube.com/vi/' . $id . '/hqdefault.jpg'; } else if ('large' === $format) { return 'https://img.youtube.com/vi/' . $id . '/sddefault.jpg'; } else if ('original' === $format) { return 'https://img.youtube.com/vi/' . $id . '/maxresdefault.jpg'; } return 'https://img.youtube.com/vi/' . $id . '/mqdefault.jpg'; } return false; } function getEmbedVideo($url) { $code = << .vec { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; } .vec iframe, .vec object, .vec embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } EEE; if (false !== ($id = getVimeoId($url))) { $code .= << EEE; } elseif (false !== ($id = getYoutubeId($url))) { $code .= << EEE; } else { $code = false; } return $code; }