Author Topic: Yet Another YouTube BBCode Tag v4.7  (Read 4588 times)

dougiefresh

  • Adminstrator
  • Expert Member
  • *****
  • Posts: 245
Yet Another YouTube BBCode Tag v4.7
« on: Nov 22, 2014, 02:08:36 PM »

YET ANOTHER YOUTUBE BBCODE TAG v4.7
By Dougiefresh -> Link to Mod


Introduction
This modification adds a BBCode to the forum that shows a YouTube video in your post.

These BBCode takes these forms:
Code: [Select]
[youtube]{youtube link}[/youtube]
[youtube width=x height=y]{youtube link}[/youtube]
[yt]{youtube ID}[/yt]
[yt {parameters}]{youtube ID}[/yt]
[yt_user]{username}[/yt_user]
[yt_user {parameters}]{username}[/yt_user]
[yt_search]{search query}[/yt_search]
[yt_search {parameters}]{search query}[/yt_search]
where width and height is specified by x and y.  If width and height aren't specified, width is 100% of the post display area and height in a 16:9 ratio to the width.

The yt_user bbcode will show videos by the specified YouTube username.

The yt_search bbcode will show videos matching the provided search phrase.

This mod should be able to display a valid YouTube video when passing URLs.  For example, all of the following will display the YouTube video at http://www.youtube.com/v/fA4cphzsjn8.
Quote
For YouTube Videos:
fA4cphzsjn8
http://www.youtube.com/fA4cphzsjn8
http://www.youtube.com/embed/fA4cphzsjn8
http://www.youtube.com/embed?v=fA4cphzsjn8
http://www.youtube.com/embed?feature=player_embedded&v=fA4cphzsjn8
http://www.youtube.com/watch?v=fA4cphzsjn8
http://www.youtube.com/v/fA4cphzsjn8
http://www.youtube.com/e/fA4cphzsjn8
http://www.youtube.com/?v=fA4cphzsjn8
http://www.youtube.com/user/username#p/u/11/fA4cphzsjn8
http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/0/fA4cphzsjn8
http://www.youtube.com/watch?feature=player_embedded&v=fA4cphzsjn8
http://www.youtube.com/?feature=player_embedded&v=fA4cphzsjn8

For YouTube PlayLists:
PL55713C70BA91BD6E
PLquckZj9TVRFKWqM6LJI4a_dgvN48jZGk
http://www.youtube.com/e/PL55713C70BA91BD6E
http://www.youtube.com/p/PL55713C70BA91BD6E
http://www.youtube.com/embed/PL55713C70BA91BD6E
http://www.youtube.com/embed?list=PL55713C70BA91BD6E
http://www.youtube.com/embed?feature=player_embedded&list=PL55713C70BA91BD6E
http://www.youtube.com/watch?v=OPf0YbXqDm0&list=PL55713C70BA91BD6E
http://www.youtube.com/?list=PL55713C70BA91BD6E
http://www.youtube.com/?feature=player_embedded&list=PL55713C70BA91BD6E
https://www.youtube.com/embed/videoseries?list=PLquckZj9TVRFKWqM6LJI4a_dgvN48jZGk
https://www.youtube.com/watch?v=Ni4ZclaiOtY&list=PLquckZj9TVRFKWqM6LJI4a_dgvN48jZGk
Substituting http://youtube.com, http://www.youtube-nocookies.com, http://youtu.be, and http://www.youtu.be also works.  https:// works instead of http://.  Please note any other parameters specified in the URL are ignored.

Optional parameters and values for all YouTube bbcodes are:
o width = Specifies the width of the iframe area.
o height = Specifies the height of the iframe area.
o start = Specifies how far into the video to start at.  Valid formats: "Seconds" or "Minutes:Seconds"
o end = Specifies how far into the video to stop at.  Valid formats: "Seconds" or "Minutes:Seconds"
o autoplay = 1, yes, on or true
o color = red or white
o theme = dark or light
o loop = 1, yes, on or true
o controls = 0, no, off, hide or false
o showinfo = 0, no, off, hide or false
o privacy = 1, yes, on or true

Profile Settings
There is a new option under Profile => Look and Layout called Show YouTube videos as a link.  Checking this box makes the mod create links instead of embedded videos in your post.

Admin Settings
This BBCode may be disabled by going into the Admin => Forum => Posts and Topics => Bulletin Board Code and unchecking the bbcodes you don't want to use.  You may also be uninstall this mod in order to disable it.

Related Discussions
o Adding option to stop mod from displaying YouTube video's as a video
o Youtube I.D parsing for new URL formats
o Need help with a Regular Expression for YouTube links....

Extra Credits Go Out To:
o Sapozhnik for code assistance
o karavan2 for providing code assistance
o kelvincool for Regular Expression assistance

Compatibility Notes
This mod was tested on SMF 2.0.10, but should work on SMF 2.1 Beta 3, as well as SMF 2.0 and up.  SMF 2.1 Beta 2 and SMF 1.x will not be supported.

Changelog
The changelog has been removed and can be seen at XPtsp.com.

License
Quote
Copyright (c) 2015 - 2017, Douglas Orend
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
« Last Edit: Jan 23, 2016, 11:11:20 AM by dougiefresh »

dougiefresh

  • Adminstrator
  • Expert Member
  • *****
  • Posts: 245
Re: Yet Another YouTube BBCode Tag v3.6
« Reply #1 on: Nov 29, 2014, 03:29:06 PM »

Below are some preview images of what the mod looks like when being used

Download Mod


FileName: Yet_Another_YouTube_BBCode_v4.7.zip
Size: 19 kb (19,494 bytes)
MD5: 7baf418e6827efb71e548e91fccaf8da
Built: Oct 17, 2017, 12:15:04 PM
Downloaded 1 times

Changelog

Uploaded v4.7 - October 17th, 2017
o Removed option to force HTTPS mode.
o Modified code to force HTTPS mode in all YouTube tags.

Uploaded v4.6 - October 9th, 2017
o Added option to force using HTTPS instead of allowing HTTP in links.

Uploaded v4.5 - August 31st, 2017
o Fixed undefined array element error in Subs-BBCode-YouTube.php.

Uploaded v4.4 - August 24th, 2017
o Fixed auto-embed so that youtu.be/RkZkekS8NQU will embed itself properly.
o Added option to allow to embed YouTube videos in signatures. (BAD IDEA!!)

Uploaded v4.3 - July 16th, 2017
o Added ability for user to full-screen the video.

Uploaded v4.2 - July 6th, 2017
o Reorganized file edits to support SMF 2.1 Beta 3 properly.
o Removed support for SMF 2.1 Beta 2.

Uploaded v4.1 - October 24th, 2016
o Added code to SimplePortal code to skip embedding links for shoutboxes.

Uploaded v4.0 - September 14th, 2016
o Added buttons for the yt_user and yt_search bbcodes.
o Added minute:second validation to start and end parameters.

Uploaded v3.11 - April 7th, 2016
o Added Spanish Latin translation by Rock Lee [BC].

Uploaded v3.10 - March 7th, 2016
o Modified auto-embed code so that YouTube URLs in signature are embedded as [url]{link}[/url].
o Merged English and English UTF8 language files together.

Uploaded v3.9 - January 24th, 2016
o Added code to make YouTube bbcode recognize content as 34-character playlist.
o Added code to force aspect ratio of width to height to be 16:9.
o Modified CSS file so that there isn't a 25px gap at the top of the video.

Uploaded v3.8 - January 23rd, 2016
o Modified new YouTube video playlist URLs support for better coverage.

Uploaded v3.7 - January 23rd, 2015
o Added support for the new YouTube video playlist URLs.
o Changed regular expression to make sure "?list=", "&list=", "?v=" and "&v=" are found first.

Uploaded v3.6 - November 30th, 2015
o Added auto-embed for YouTube URLs.

Uploaded v3.5 - November 4th, 2015
o SMF 2.1: Fixed BBCode-YouTube.css install location.

Uploaded v3.4 - August 21st, 2015
o Fixed issue where necessary tag cannot be added if other mods have modified same lines.
o Rewrote the "fix parameter order" function to be called only when necessary.
o Operation that calls "fix parameter order" function now skipped for nightly SMF 2.1 Beta 2.

Uploaded v3.3 - August 12th, 2015
o Added settings to allow admin to set default size of the YouTube video.
o Altered code to use new default size settings when width and/or height isn't specified.

Uploaded v3.2 - August 8th, 2015
o Removed support for SMF 2.1 Beta 1
o Added support for SMF 2.1 Beta 2

Uploaded v3.1 - August 1st, 2015
o Performance increase due to modification of parse_bbc function to deal with memory issue found.

Uploaded v3.0 - July 17th, 2015
o CrescentEclipse added responsive video display elements to this mod.  Thanks, CrescentEclipse!
o When specifying width and height parameters, they are now treated as maximum display size.
o Changed default width and height from 640x400 to 100% of post display area.
o Modified "start" and "end" parameters to use "minutes:seconds" format in addition to "seconds".

Uploaded v2.5 - April 13th, 2015
o Fixed mistake introduced in v2.4 regarding YouTube links.

Uploaded v2.4 - April 12th, 2015
o Fixed YouTube URLs used for mobile devices.

Uploaded v2.3 - May 1st, 2015
o Fixed missing BBCode button in editor for SMF 2.1 Beta 1.
o Fixed a bug where using YouTube ID instead of URL showed error message.

Uploaded v2.2 - April 6th, 2015
o Updated for SMF 2.1 Beta 1

Uploaded v2.1 - February 19th, 2015
o Readded code segment from v1.8 that dealt with "method of last resort" video ID.

Uploaded v2.0 - February 19th, 2015
o YouTube videos are now displayed using the iframe tag for HTML5 compatibility.
o http://www.youtube-nocookie.com is now a valid URL to specify in the bbcode.
o Added yt_user bbcode to create a playlist of YouTube videos by a specific user.
o Added yt_search bbcode to create a playlist based on specified search results.
o Added support for YouTube playlist IDs as part of the youtube and yt bbcodes.
o Modification made to BBCode hook to define all bbcode parameters only ONCE for uniformity.
o Fixed a bug in the validation function that didn't set width/height parameters correctly.
o Modified validation function to work properly for all known YouTube video/playlist URLs with IDs.
o Parameters width and height are now optional instead of mandatory.
o Fixed an issue where the video's aspect ratio is screwed up if width or height isn't specified.
o Added autoplay parameter to the bbcodes.  1, yes, on and true are supported.
o Added color parameter to the bbcodes.  red and white are supported by YouTube.
o Added theme parameter to the bbcodes.  dark and light are supported by YouTube.
o Added loop parameter to the bbcodes.  1, yes, on and true are supported.
o Added start parameter to the bbcodes, specifying the number of seconds into the video to start at.
o Added end parameter to the bbcodess, specifying the number of seconds into the video to stop at.
o Added controls parameter to the bbcodes.  0, no, off, hide and false are supported.
o Added showinfo parameter to the bbcodes.  0, no, off, hide and false are supported.
o Added privacy parameter to the bbcodes.  1, yes, on and true are supported.
o http://www.youtube-nocookie.com is used in privacy mode, as supported by YouTube.

Uploaded v1.8 - February 18th, 2015
o Updated Regular Expression used to validate the last few reported forms of the YouTube URL.
o Added some backup code in the event that the Regular Expression doesn't catch a valid URL.

Uploaded v1.7 - January 19th, 2015
o License change to Simplified BSD.  No functionality change.

Uploaded v1.6 - December 29th, 2014
o Fixed image install locations within package-info.xml.
o Replaced replace with after in install.xml for new code in v1.5...

Uploaded v1.5 - December 28th, 2014
o Added yt bbcode, which uses same syntax as the youtube bbcode.
o Added option to disable the embedding of YouTube videos on a per-user basis.
o Modified to use link provided when YouTube bbcode is disabled.

Uploaded v1.4 - December 19th, 2014
o Fixed typo that resulted in errors being logged in the admin panel...

Uploaded v1.3 - December 17th, 2014
o Rewrote mod to use one validation function for all bbcodes forms in this mod.
o Modified code to return "Invalid YouTube Link" if the link isn't valid...

Uploaded v1.2 - December 11th, 2014
o Fixed incorrect strings added by the mod.

Uploaded v1.1 - December 10th, 2014
o Added button for the bbcode.

Uploaded v1.0 - November 22th, 2014
o Initial Release of the mod

Translations

Quote
$txt['youtube_link_invalid'] = '[ Invalid YouTube link ]';
« Last Edit: Oct 29, 2016, 08:18:17 PM by dougiefresh »