how to constrain size of youtube embed iframe size?
The youtube embed code's general structure is like this:
<iframe width="560" height="349" src="http://www.youtube.com/embed/MiYND_zvIc0" frameb开发者_如何学Corder="0" allowfullscreen></iframe>
I want users to upload this code to my SQL table and then I will retrieve and output all the embed codes from the SQL table. The problem is that I have no choice as to what width or height the iframe is going to be since the users are making the embed codes through youtube's site.
Let's say I have 20 instances of the code I posted above and I want to auto-resize all the iframes to 640 x 480 when they get retrieved. How do I do this?
first, use substr function with strpos to grab and save 3 things in you database:
- youtube id
- width
- height
second, use substr_replace function to change the value of all instances depending on your needs
精彩评论