Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Im looking to embed a youtube video from a parameter on a doc type.
I want it to be as generic as possible, so the user doesn't have to worry about finding the exact ID but can just copy the entire url fromyoutube.
So i need to extract the ID from the url
https://www.youtube.com/watch?v=w59e20ijOpE
That would mean getting 11 characters after the "=" character, resulting in:
w59e20ijOpE
How would one do this in razor?
How about something ilke this
var youTubeId = Model.Content.GetPropertyValue<string>("myYouTubePropertyAlias").Split('=').Last()
Thanks. Thats great. I fiddled around a bit and got this:
string myString = CurrentPage.youtubeID; int charPositionStart = myString.IndexOf("="); int lengthOfText = 11; myString = myString.Substring(charPositionStart+1, lengthOfText);
That would make it work as well if the url doesnt stop with the ID, like:
https://www.youtube.com/watch?v=p69z3zytU6I&list=LLzZhNDYY7C2h9-2oqcrziJQ
This might be more robust
var uri = new Uri(Model.Content.GetPropertyValue<string>("myYouTubePropertyAlias")); var query = HttpUtility.ParseQueryString(uri.Query); var youTubeId = query.Get("v");
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Extract Youtube ID from url
Im looking to embed a youtube video from a parameter on a doc type.
I want it to be as generic as possible, so the user doesn't have to worry about finding the exact ID but can just copy the entire url fromyoutube.
So i need to extract the ID from the url
That would mean getting 11 characters after the "=" character, resulting in:
How would one do this in razor?
How about something ilke this
Thanks. Thats great. I fiddled around a bit and got this:
That would make it work as well if the url doesnt stop with the ID, like:
This might be more robust
is working on a reply...