Page 1 of 1

Does anyone know how sites like reddit let users embed video

Posted: Sun Mar 07, 2010 10:51 pm
by scarface222
I am trying to implement a system that will let a user submit a video link and then display the video but I am having a little bit of difficulty. I tried submitting the whole object video into database, but when I use mysql_real_escape_string, it leaves the link unusable because it adds \" and escapes quotations. However, if I was to just use the link of the site I wouldn't know how to identify the post as a video.

Does anyone know the process sites like digg and reddit use to ensure the video is displayed correctly, can be identified as a video, and will support embeds from different sites? If anyone is an expert on this, I would really appreciate any suggestions.

Thanks in advance

Re: Does anyone know how sites like reddit let users embed video

Posted: Mon Mar 08, 2010 10:22 am
by scarface222
nvm i used striplashes on the submitted object link. If anyone has anything to add though I would still really appreciate it.

Re: Does anyone know how sites like reddit let users embed video

Posted: Mon Mar 08, 2010 10:45 am
by AbraCadaver
The problem with the slashes is that you have magic_quotes turned on. So when the data is posted, PHP automagically adds the slashes, then you do it again with mysql_real_escape_string(). You should either turn off magic_quotes, or run stripslashes() before running mysql_real_escape_string().

Re: Does anyone know how sites like reddit let users embed video

Posted: Mon Mar 08, 2010 11:09 am
by scarface222
thanks man I looked into that, I am not exactly sure what the point of the quotes are (prevent developers from being prone to injection, i thought mysql_real_escape_string did that?) but they are apparently removed in php 6. I just have one more question. In large resolutions, the page is fine but it extends a bit farther then it should, so I looked at the object, and it seems there is a large variety of widths and height possibilities, so I wanted to use a uniform height and width for all videos, but since youtube and vimeo players for example are different embed links, should I just try to use preg replace to match all resolution possibilities on youtube and replace with a moderate sized one? Any suggestions on that?