@@ -59,6 +59,10 @@ function videoembed_create_embed_object($url, $guid, $videowidth=0, $input) {
59
59
return videoembed_teachertube_handler ($ url , $ guid , $ videowidth );
60
60
} else if (strpos ($ url , 'hulu.com ' ) != false ) {
61
61
return videoembed_hulu_handler ($ url , $ guid , $ videowidth );
62
+ } else if (strpos ($ url , 'instagram.com ' ) != false ) {
63
+ return videoembed_instagram_handler ($ url , $ guid , $ videowidth );
64
+ } else if (strpos ($ url , 'instagr.am ' ) != false ) {
65
+ return videoembed_instagram_shortener_parse_url ($ url , $ guid , $ videowidth );
62
66
}
63
67
64
68
if (!$ input ) {
@@ -130,6 +134,8 @@ function videoembed_add_object($type, $url, $guid, $width, $height) {
130
134
case 'hulu ' :
131
135
$ videodiv .= "<object width= \"{$ width }\" height= \"{$ height }\"><param name= \"movie \" value= \"http://www.hulu.com/embed/ {$ url }\"></param><param name= \"allowFullScreen \" value= \"true \"></param><embed src= \"http://www.hulu.com/embed/ {$ url }\" type= \"application/x-shockwave-flash \" allowFullScreen= \"true \" width= \"{$ width }\" height= \"{$ height }\"></embed></object> " ;
132
136
break ;
137
+ case 'instagram ' :
138
+ $ videodiv .= "<iframe src= \"{$ url }embed/ \" width= \"$ width \" height= \"$ height \" frameborder= \"0 \" scrolling= \"no \" allowtransparency= \"true \"></iframe> " ;
133
139
}
134
140
135
141
$ videodiv .= "</div> " ;
@@ -751,3 +757,30 @@ function videoembed_hulu_parse_url($url) {
751
757
752
758
return $ hash ;
753
759
}
760
+
761
+ function videoembed_instagram_handler ($ url , $ guid , $ videowidth ) {
762
+ if (!isset ($ url )) {
763
+ return '<p><b> ' . elgg_echo ('embedvideo:parseerror ' , array ('instagram ' )) . '</b></p> ' ;
764
+ }
765
+
766
+ videoembed_calc_size ($ videowidth , $ videoheight , 425 /320 , 24 );
767
+
768
+ $ embed_object = videoembed_add_css ($ guid , $ videowidth , $ videoheight );
769
+
770
+ $ embed_object .= videoembed_add_object ('instagram ' , $ url , $ guid , $ videowidth , $ videoheight );
771
+
772
+ return $ embed_object ;
773
+ }
774
+
775
+ function videoembed_instagram_shortener_parse_url ($ url , $ guid , $ videowidth ) {
776
+ $ path = parse_url ($ url , PHP_URL_PATH );
777
+ $ videourl = 'https://instagram.com ' . $ path ;
778
+
779
+ videoembed_calc_size ($ videowidth , $ videoheight , 425 /320 , 24 );
780
+
781
+ $ embed_object = videoembed_add_css ($ guid , $ videowidth , $ videoheight );
782
+
783
+ $ embed_object .= videoembed_add_object ('instagram ' , $ videourl , $ guid , $ videowidth , $ videoheight );
784
+
785
+ return $ embed_object ;
786
+ }
0 commit comments