View Single Post
  #68  
Old 04-07-2016, 11:48 PM
TheBang TheBang is offline
 
Join Date: Aug 2010
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I spent about 5 hours today working on modifying this to create a modern Auto YouTube Embed mod for my vBulletin 3.8 board (though this should also work on 4.x boards), and I thought I would share it here. This is a simple way for bare YouTube URL's in posts to be automatically converted to embedded video.

What it detects/auto-converts:

It will only match on URL's that are in BB code [url] links. I tried to make it match non-linked URLs, but it was a bad idea because it wreaked havoc with BB code tags that might have YouTube URL's in them, like [code] or custom [youtube] tags.

By default, vBulletin auto-[url] links text that starts with www, http, or https. That means this will match most YouTube URLs that users might put in their post, but text like m.youtube.com/watch?v=XXXXXXXXXXX would not match, unless the user explicitly puts [url] tags around it, because vBulletin would not auto-link it.

It will handle both HTTP and HTTPS URLs

It will handle www, m, or no prefix.

It will handle youtu.be and youtube.com URLs. Besides .com, it will also handle de, jp, ca, co, ch, au, net, and be.

It will handle YouTube URL's in the following forms: watch?v=, v/, e/, embed/

It will not pass through parameters in the URL like "autoplay=1" or "loop=1" or, unfortunately, start times (t=4m3s, for example), but it will not be tripped up by them either.

What it outputs:

It outputs iframe embedding code, which is the YouTube-preferred embedding method. This allows either the HTML5 player or Flash player to be used, depending on the browser's capabilities.

Fullscreen is enabled

16:9 embedded aspect ratio (700x394 pixels). If you want to change the size, simply edit the width and height in the XML file before installing.
Attached Files
File Type: xml product-youtubeplayer-iframe.xml (1.3 KB, 88 views)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01142 seconds
  • Memory Usage 1,782KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_attachment
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete