Results 1 to 18 of 18

Thread: Enable Video Embedding

  1. #1
    Join Date
    Sep 2008
    Posts
    24

    Default Enable Video Embedding

    I want to enable video embedding in entries but WITHOUT allowing HTML as I believe that is a security flaw.

    Any mods/hacks/workarounds... to enable a minimum of YOUTUBE embedding would be awesome. I'm guessing it is SOMEHOW possible using BBCode although I'm not sure?

    I'm also not opposed to using custom fields for videos if this would make the whole mod/hack process easier! Let me know - Any help greatly appreciated!

    Thanks in advance!

  2. #2
    Join Date
    Sep 2008
    Posts
    24

    Default

    Bump - need this!

  3. #3
    Join Date
    Aug 2004
    Posts
    353

    Default

    Create a new custom field, simple text input. Mark down the custom field id.

    This is the youtube url:

    http://www.youtube.com/watch?v=bq1_6D9QS9Y

    This is what you put in the custom field area:

    bq1_6D9QS9Y

    Put this in your ADV_DYNA_SHOWENTRY template where you want the video to play:

    <if condition="$entry[fieldXXX]">

    <object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/$entry[fieldXXX]&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/$entry[fieldXXX]&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>

    </if>

    $entry[fieldXXX] = replace XXX with the number of the custom field you marked down earlier.

    You can also put this in your entrybit_expanded template.

    Not perfect solution, but that's the closest thing without hacking in to the files. I use a media embedder on the forums, i dont think it translates to the Dyna instances tho. You can find the auto-embedder on vbulletin.org.

  4. #4
    Join Date
    Sep 2008
    Posts
    24

    Default

    I guess thats an okay temporary solution. But then you have the cases where you'll want additional YouTube videos. Or no YouTube videos. And it just makes the entry process more sloppy with more fields.

    Could you just use regular BB Code and have them rap [YouTube]Url[YouTube] tags around the Url in the regular entry and have it display? That's another option... albeit not a perfect one.

    In any case thanks for your help and offering at least one viable solution. Although, I'll be interested to hear if there are others.

  5. #5

    Default

    I did this and it added a big gap of space in the module at the top and the bottom.

    site is RadarDetectorLaser.com

    look at homepage on the right inside the module on the bottom, how do i get rid of this space?

    <!-- Embed Video Code Start -->
    <if condition="THIS_SCRIPT == 'dyna_index'">
    <object width="300" height="255"><param name="movie" value="http://www.youtube.com/v/8mi4nSWRtBM&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/8mi4nSWRtBM&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="300" height="255"></embed></object>
    </else></if>
    <br>
    <if condition="THIS_SCRIPT == 'dyna_index'">
    <object width="300" height="255"><param name="movie" value="http://www.youtube.com/v/FVE6724e85M&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/FVE6724e85M&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="300" height="255"></embed></object>
    </else></if>
    <br>
    <if condition="THIS_SCRIPT == 'dyna_index'">
    <object width="300" height="255"><param name="movie" value="http://www.youtube.com/v/32YnUeeq5Lg&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/32YnUeeq5Lg&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="300" height="255"></embed></object>
    </else></if>
    <br>
    <if condition="THIS_SCRIPT == 'dyna_index'">
    <object width="300" height="255"><param name="movie" value="http://www.youtube.com/v/CtBcF47lzkA&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/CtBcF47lzkA&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="300" height="255"></embed></object>
    </else></if>
    <!-- Embed Video Code End -->

  6. #6

    Default

    anyone?

  7. #7
    Join Date
    Jul 2007
    Location
    Vermont
    Posts
    247

    Default

    YouTube is easy to do with BBCode. I got this from vbulletin.com, so I can't take credit...

    AdminCP > Custom BB Codes > Add New

    Title: YouTube
    Tag Name: youtube
    Replacement:
    Code:
    <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/{param}"></param><embed src="http://www.youtube.com/v/{param}" type="application/x-shockwave-flash" width="425" height="350"></embed></object>
    Example: [youtube]JFwCCL0Vh6U[/youtube]
    Use Option: No
    Last four options: Yes, No, No, No (at least that's what I have and it works)

    As for an image for the button, you can use the one attached to this post. I'm not sure who created the button.

  8. #8
    Join Date
    Feb 2008
    Posts
    296

    Default

    Is there any way that a user could just paste the YouTube URL like:

    Code:
    http://www.youtube.com/watch?v=QIvBQhiWUZk
    and then use the bbcode instead of just the id - it would make it easier for users

  9. #9
    Join Date
    Jan 2004
    Location
    Georgia, USA
    Posts
    34,466

    Default

    Quote Originally Posted by caitian View Post
    Is there any way that a user could just paste the YouTube URL like:
    Use this for your replacement instead:
    Code:
    <object width="425" height="350"><param name="movie" value="{param}"></param><embed src="{param}" type="application/x-shockwave-flash" width="425" height="350"></embed></object>
    Then you'll probably want to add a plugin to the 'bbcode_parse_start' hook location with the following code to make sure that's only parsing URL's from youtube.
    Code:
    $ytcheck = stripos($text, '[youtube]');
    if ($ytcheck !== false)
    {
        $text = str_replace('http://www.youtube.com/watch?v=', 'http://www.youtube.com/v/', $text);
    
        $ytcheckend = stripos($text, '[/youtube]');
    
        $yturl = substr($text, $ytcheck + 9, -10);
       // If it's not pointing to youtube.com, remove the tag
        if (substr($yturl, 0, 25) != 'http://www.youtube.com/v/' AND substr($yturl, 0, 22) != 'http://youtube.com/v/')
        {
            $text1 = substr($text, 0, $ytcheck);
            $text2 = substr($text, $ytcheckend + 10);
    
            $text = $text1 . $text2;
        }
    }
    That code will check the URL entered between the [youtube] [/youtube] tags. If it doesn't point to youtube.com, the entire tag is removed before the rest of the code is parsed.
    Last edited by Brian; 06-18-2009 at 12:36 PM.

  10. #10
    Join Date
    Feb 2008
    Posts
    296

    Default

    Thanks Brian - I created the bbcode and added the plugin but unfortunately it didn't work - a test post that I created in Dynamics just shows a large white space where the youtube should be but it isn't displayed

  11. #11
    Join Date
    Jan 2004
    Location
    Georgia, USA
    Posts
    34,466

    Default

    Can you post the exact code you tried to use in your post here?

  12. #12
    Join Date
    Feb 2008
    Posts
    296

    Default

    Thanks Brian...as always!

    Created a bbcode:
    Title: youtube BBcode
    BB Code Tag Name: youtube
    Replacement:
    Code:
    <object width="425" height="350"><param name="movie" value="{param}"></param><embed src="{param}" type="application/x-shockwave-flash" width="425" height="350"></embed></object>
    Example:
    Code:
    [youtube]http://www.youtube.com/watch?v=QIvBQhiWUZk[/youtube]
    Use {option}: No
    Button Image (Optional): ../forum/images/editor/youtube.gif
    Remove Tag If Empty: Yes
    Disable BB Code Within This BB Code: No
    Disable Smilies Within This BB Code: No
    Disable Word Wrapping Within This BB Code: No

    New Plugin in Plugin Manager:
    Product: vBulletin
    Hook Location: bbcode_parse_start
    Title: You Tube Parse
    Execution Order: 5
    Plugin PHP Code:
    Code:
    $ytcheck = strpos($text, '[youtube]');
    if ($ytcheck)
    {
        $ytcheckend = strpos($text, '[/youtube]');
    
        $yturl = substr($text, $ytcheck + 9, -10);
        if (substr($yturl, 0, 25) != 'http://www.youtube.com/v/' AND substr($yturl, 0, 22) != 'http://youtube.com/v/')
        {
            $text1 = substr($text, 0, $ytcheck);
            $text2 = substr($text, $ytcheckend + 10);
    
            $text = $text1 . $text2;
        }
    }
    Plugin is Active: Yes

    Created a Dynamics entry using the bbcode:
    Attachment 5321

    Result is displayed as:
    Attachment 5322

  13. #13
    Join Date
    Jan 2004
    Location
    Georgia, USA
    Posts
    34,466

    Default

    I think I was using the URL from the URL from the "Embed" code at youtube instead of the URL provided there. I just updated the plugin code from my original post, so try updating your plugin with the new code and that *should * do the trick.
    Note you may need to rebuild your post cache after making that change before you will see any difference (Admin CP => Maintenance => Update Counters => Rebuild Post Cache)

  14. #14
    Join Date
    Feb 2008
    Posts
    296

    Default

    Something must be wrong with what I am doing Brian as I am sure you have tested this on your own setup but it still isn't working for me.

    I replaced the plugin code with the new one that uses the string replace, updated the cache and created a new test entry in Dynamics that includes a piece if text followed by a You Tube entry wrapped in the bbcode and I still receive just an expanded white space.

  15. #15
    Join Date
    Jan 2004
    Location
    Georgia, USA
    Posts
    34,466

    Default

    Werid... Can you link me to that test entry, or view the source code and post it here?

  16. #16
    Join Date
    Feb 2008
    Posts
    296

    Default

    Brian, I have sent a PM with the details - thanks!

  17. #17
    Join Date
    Jan 2004
    Location
    Georgia, USA
    Posts
    34,466

    Default

    I found the problem... I was testing with lowercase [youtube] tags while you were using uppercase. I went ahead and updated your plugin and the code I posted above to use stripos() instead of strpos() when checking for the and that seems to have done the trick.

  18. #18
    Join Date
    Feb 2008
    Posts
    296

    Default

    Thanks so much "Sir" Brian - as always!

    No doubt this may help others

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Media Embedding
    By insidedesign in forum Feedback & Suggestions
    Replies: 0
    Last Post: 07-28-2008, 06:08 PM
  2. Auto Media Embedding
    By ManagerJosh in forum "How Do I..." Questions
    Replies: 2
    Last Post: 03-13-2008, 02:23 AM
  3. Strange problem with embedding video
    By ZGeek in forum Module & Modification Discussion & Requests
    Replies: 2
    Last Post: 10-26-2007, 07:52 PM
  4. Forum embedding
    By headcase420 in forum Troubleshooting & Problems
    Replies: 2
    Last Post: 12-08-2005, 05:03 PM
  5. Clicking video link on left displays video in the centre
    By Renada in forum "How Do I..." Questions
    Replies: 2
    Last Post: 08-16-2005, 10:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •