• View our reviews on Hot Scripts
  • JS Tutorial

Recent Comments

Powered by Disqus

Back to articles

Get information about video and images from link

Media Embed class allows you to retrieve information about media like Video or Images by simply using link or embed code from media providers like Youtube, Myspace, etc.

It can retrieve embeding codes, title, sizes and thumbnails from more than 20 popular media providers



Example codes


//include class

//provide media link
$em = new media_embed('');

//check if found anything useful
$site = $em->get_site();
if($site != "")
    echo "<p>Link to media:</p>";
    echo "<p><a href='".$em->get_url()."'>";
    $size = $em->get_size();
    echo "<img src='".$em->get_thumb("small")."'/>";
    echo "</a></p>";
    echo "<p>Or embed it:</p>";
    echo "<p>";
    $code = $em->get_iframe();
    if($code == "")
        $code = $em->get_embed();
    echo $code;
    echo "</p>";
    echo "<h3>Cannot get info from this source</h3>";

Examples in action

Example scripts provided with package in action:

Method list


Back to method list

Method namenew media_embed($data)
DescriptionCreate instance of class from provided information about media content
Input parameters

string $data - information about media, for example link to media website, or it's embed code

Example input
new media_embed("");

Get media thumbnail

Back to method list

Method nameget_thumb($size = "small")
DescriptionReturns URL to Media thumbnail
Input parameters

string $size - size of thumbnail, supports 3 values: small, medium, large. (default: small)

Get iframe code

Back to method list

Method nameget_iframe($w = -1, $h = -1)
DescriptionReturns Iframe code for media embedding
Input parameters

int $w - width of embeded video. (default: -1, means default width is used)

int $h - height of embeded video. (default: -1, means default height is used)

Example inputget_iframe(320, 200)
Example output<iframe width="320" height="200" src="" frameborder="0" allowfullscreen></iframe>

Get embed code

Back to method list

Method nameget_embed($w = -1, $h = -1)
DescriptionReturns object/embed code for media embedding
Input parameters

int $w - width of embeded video. (default: -1, means default width is used)

int $h - height of embeded video. (default: -1, means default height is used)

Example inputget_embed(320, 200)
Example output<object width="320" height="200" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param name="movie" value=""></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="200"></embed></object>


Back to method list

Method nameget_url()
DescriptionReturns URL of media's webpage
Example output

Get media id

Back to method list

Method nameget_id()
DescriptionReturns Identification code of media
Example outputxxxxxxxxxx

Get website URL

Back to method list

Method nameget_site()
DescriptionReturns URL of website where media was embeded
Example output

Get dimensions of video

Back to method list

Method nameget_size()
DescriptionReturns array with dimensions of video, where "w" represents width and "h" - height
Example output
	"w" => 320
	"h" => 240

Get Title of media

Back to method list

Method nameget_title()
DescriptionReturns title of provided media
Example outputAwesome Video

Supported websites

Here is a list of all supported media providers

WebsiteData supported as inputSupported methods
5minVideo URL, Embed codeAll
Blip.tvVideo URLAll
ClickthroughVideo URL, Embed codeAll
DailymotionVideo URL, Embed code, Iframe codeAll
DotsubVideo URL, Embed codeAll
FacebookVideo URL, Embed codeAll
FlickrImage URLDoesn't support iframe and embed methods. Returns size of medium size image.
Funny or DieVideo URLAll
HuluVideo URLAll
MetacafeVideo URL, Embed codeAll
MyspaceVideo URL, Embed code, Hulu codeAll
Qik.comVideo URLAll
Revision3Video URLAll
RevverVideo URL, Embed code, Flash code, QuickTime code, Javascript code, Image codeAll exept get_iframe() (causes download dialog)
ScreenrVideo URLAll except get_embed()
SlideshareVideo URLAll except get_embed()
TwitpicImage URLSupports only get_thumb method for all 3 sizes
ViddlerVideo URLAll
VideojugVideo URLAll
VimeoVideo URL, Embed code, Iframe codeAll
YfrogImage URL, Video URL,Image doesn't support iframe and embed methods and returns size of large size image. Video supports all methods
YoutubeVideo URL, Short URL, Embed code, Iframe codeAll

Latest changes

None for now

Rate us

Like our script? Rate it at PHP > Hot Scripts

Try it out and Rate on


PHP classes support forum or comments below

You may also be interested in:

Powered by

blog comments powered by Disqus