使用 php 调整嵌入视频的大小
你好,我正在尝试开发一个视频库
然而问题是我应该限制它们的尺寸。 因此,如果网站所有者想要添加视频,他应该粘贴嵌入代码。
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/R6uJGqS-KQY?fs=1&hl=el_GR"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/R6uJGqS-KQY?fs=1&hl=el_GR" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
我决定使用嵌入,因为那里有很多视频提供商......
那么在将其存储到数据库之前调整其大小的最佳方法是什么?
有没有仅 CSS 的解决方案?
我还注意到 video.google 仅使用内联 css 来表示宽度和高度!这将覆盖任何 css 设置...
那么正则表达式是唯一的解决方案吗?
Hello i am trying to develop a video gallery
However the problem is that i should limit their dimensions.
So if the site owner wants to add a video he should paste the embed code..
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/R6uJGqS-KQY?fs=1&hl=el_GR"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/R6uJGqS-KQY?fs=1&hl=el_GR" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
I decided to go with embed because there are many video providers out there....
So which is the best method to resize it before storing it to the database?
IS there a css only solution?
Also i noticed that video.google uses only and inline css for width height! That would overide any css setting...
So regexp is the only solution ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我必须做类似的任务,我会将 html 转换为 xml 并获取高度/宽度。
之后,我会调整高度或宽度的大小(取决于您的需要)以保持外观。
这样做不会调整实际视频的大小,但会帮助您通过 HTML 调整视频的大小。
我已经对此进行了测试,您可以在以下位置查看它的实际效果:
演示:http://itnews-bg.com/test.php
来源:http://itnews-bg.com/test.phps
可能有其他更好的方法,但这就是我会做的。
希望对你有帮助:)
If I had to do a similar task I would convert the html into xml and get the height/width.
After that I would resize the height or width (depending on what you need) keeping the aspect.
Doing this will not resize the actual video but it'll help you to resize it via HTML.
I've tested this and you can see it in action at:
Demo: http://itnews-bg.com/test.php
Source: http://itnews-bg.com/test.phps
There may be other better ways but this is what I would do.
Hope it helps you :)
当我必须使用 dailymotion 视频的嵌入代码时,这会出现错误:
That provides error when i have to use embed code of dailymotion video: