Created
August 24, 2019 12:10
-
-
Save tomrutgers/826127ea9644f55f568e1d2b006d2eff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_embed_url(url) | |
| provider = url.match(/https:\/\/(:?www.)?(\w*)/)[2] | |
| if provider == "youtube" | |
| id = url.match(/https:\/\/(?:www.)?(\w*).com\/.*v=(\w*)/)[2]; | |
| "https://www.youtube.com/embed/#{id}" | |
| elsif (provider == "vimeo") | |
| id = url.match(/https:\/\/(?:www.)?(\w*).com\/(\d*)/)[2]; | |
| "https://player.vimeo.com/video/#{id}" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment