Warning: The author of this contribution does not provide support for it anymore.

Advanced BBCode Box 3

https issue please help - Advanced BBCode Box 3

https issue please help

by bernard@goji » Tue May 09, 2017 4:52 am

Hello,

After switching my site over to SSL, the embedded youtube video previews are not displaying, just a grey background. I love this mod, been using it for years, is there a way to fix this issue?

Please help
bernard@goji
Registered User
Posts: 3
Joined: Tue May 09, 2017 3:47 am
Contact:

Re: https issue please help

by PiperB » Sun Apr 08, 2018 6:58 pm

Updated: Update on the replacement below.
Begin by making backups of all files you are editing. (This way if you ever lose your certificates or go back to http again you can replace the edited files with the old ones and vice versa.)

Next....

Open: /includes/abbcode.php

Find:

Code: Select all

			'youtube.com' => array(
				'id'		=> 43,
				'image'		=> 'youtube.gif',
				'example'	=> 'http://www.youtube.com/watch?v=sP4NMoJcFd4',
				'match'		=> '#https?://(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)([^[]*)?#i', // matches every youtube URL
//				'replace'	=> '<iframe width="{WIDTH}" height="{HEIGHT}" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>',
				'replace'	=> 'http://www.youtube.com/v/$1?version=3&hl=en_US',
				'method'	=> 'flash',
			),
			'youtu.be' => array(
				'id'		=> 49,
				'image'		=> 'youtube.gif',
				'example'	=> 'http://youtu.be/sP4NMoJcFd4',
				'match'		=> '#https?://(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)([^[]*)?#i', // matches every youtube URL
//				'replace'	=> '<iframe width="{WIDTH}" height="{HEIGHT}" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>',
				'replace'	=> 'http://www.youtube.com/v/$1?version=3&hl=en_US',
				'method'	=> 'flash',
                        ),


Replace with: (Updated to fix a debug error from the old code of this mod. Explained in more detail in the next post.)

Code: Select all

			'youtube.com' => array(
				'id'		=> 43,
				'image'		=> 'youtube.gif',
				'example'	=> 'http://www.youtube.com/watch?v=sP4NMoJcFd4',
				'match'		=> '#https?://(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)([^[]*)?#i', // matches every youtube URL
                                'replace'	=> '<iframe width="{WIDTH}" height="{HEIGHT}" src="https://www.youtube.com/embed/$1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
			),
			'youtu.be' => array(
				'id'		=> 49,
				'image'		=> 'youtube.gif',
				'example'	=> 'http://youtu.be/sP4NMoJcFd4',
				'match'		=> '#https?://(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)([^[]*)?#i', // matches every youtube URL
		                'replace'	=> '<iframe width="{WIDTH}" height="{HEIGHT}" src="https://www.youtube.com/embed/$1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
			),
Save the file.

Open: /language/en/mods/abbcode.php

Find:

Code: Select all

	'ABBC3_BBVIDEO_EXAMPLE'		=> 'http://www.youtube.com/watch?v=sP4NMoJcFd4',
	'ABBC3_BBVIDEO_VIEW'		=> '[BBvideo 560,340]http://www.youtube.com/watch?v=sP4NMoJcFd4[/BBvideo]',
Replace with:

Code: Select all

	'ABBC3_BBVIDEO_EXAMPLE'		=> 'https://www.youtube.com/watch?v=sP4NMoJcFd4',
	'ABBC3_BBVIDEO_VIEW'		=> '[BBvideo 560,340]https://www.youtube.com/watch?v=sP4NMoJcFd4[/BBvideo]',
Find:

Code: Select all

	'ABBC3_YOUTUBE_EXAMPLE'		=> 'http://www.youtube.com/watch?v=sP4NMoJcFd4',
	'ABBC3_YOUTUBE_VIEW'		=> '[youtube]http://www.youtube.com/watch?v=sP4NMoJcFd4[/youtube]',
Replace with:

Code: Select all

	'ABBC3_YOUTUBE_EXAMPLE'		=> 'https://www.youtube.com/watch?v=sP4NMoJcFd4',
	'ABBC3_YOUTUBE_VIEW'		=> '[youtube]https://www.youtube.com/watch?v=sP4NMoJcFd4[/youtube]',
Save the file.

Clear your cache and refresh templates, and everything just for good measure, although neither are required in this case.

The first file edits correct the issue with the youtube videos not displaying if they are already http instead of https. The second file edits are just the language display as It changes the example text displayed to members in the posting editor, letting them know to use https instead of http. :)
Last edited by PiperB on Mon May 07, 2018 5:10 pm
<!-- IF U_LOVE_NOTEPAD++ -->
[td class=statement]I Notepad++ ![/td]
<!-- ENDNEVER --> <!-- tee hee --> :P
Whoa ooo whoa ooo whoa I'm a Lady!
User avatar
PiperB
Registered User
Posts: 173
Joined: Mon Nov 07, 2016 6:54 pm
Contact:

Re: https issue please help

by PiperB » Sun May 06, 2018 8:56 pm

Bumping this because I updated the first replacement in the post above to fix another issue with the old code of this mod, for people who are still using it.

With the old code the way it was it was causing a browser debug error like this.
debug error via browser wrote:Rewriting old-style YouTube Flash embed (https://www.youtube.com/v/ZGl8vrceu1E?v ... 3&hl=en_US) to iframe embed (https://www.youtube.com/embed/ZGl8vrceu ... 3&hl=en_US). Please update page to use iframe instead of embed/object, if possible.
With this fix for the mod version It now not only loads the videos via youtube ssl on the https but it also no longer has the debug error and the browser won't have this error upon debug. Videos load. The fix is the 1st replacement in the post above. :)

Edit:
If you have the Add-on : Open YouTube videos with Lightboxes installed then you should change that as well to play the https vids.

Here are the changes for that addon.

Open: /includes/abbcode.php

Find:

Code: Select all

				// ADD-ON: Open YouTube videos with Lightboxes - START
				if (($video_name === 'youtube.com' || $video_name === 'youtu.be') && $this->abbcode_config['S_ABBC3_RESIZE'] && in_array($this->abbcode_config['S_ABBC3_RESIZE_METHOD'], array('HighslideBox', 'Lightview', 'prettyPhoto', 'Shadowbox')))
				{
					$identifier = (preg_match($video_data['match'], $in, $matches) ? $matches[1] : '');
					$bb_thumb = 'http://img.youtube.com/vi/' . $identifier . '/2.jpg';

					switch ($this->abbcode_config['S_ABBC3_RESIZE_METHOD'])
					{
						case 'HighslideBox':
							$bb_class = 'highslide';
							$bb_link = 'http://www.youtube.com/embed/' . $identifier . '?rel=0&amp;wmode=transparent&amp;autoplay=1';
							$bb_attribs = 'onclick="return hs.htmlExpand(this, {objectType: \'iframe\', width: ' . $video_width . ', height: ' . $video_height . ', allowSizeReduction: false, wrapperClassName: \'draggable-header no-footer\', numberPosition: null, preserveContent: false, objectLoadTime: \'after\'})"';
						break;

						case 'Lightview':
							$bb_class = 'lightview';
							$bb_link = 'http://www.youtube.com/v/' . $identifier . '&amp;fs=1&amp;rel=0&amp;autoplay=1';
							$bb_attribs = 'rel="flash" title=" :: :: width: ' . $video_width . ', height: ' . $video_height . '"';
						break;

						case 'prettyPhoto':
							$bb_class = 'prettyPhoto';
							$bb_link = 'http://www.youtube.com/watch?v=' . $identifier . '&amp;width=' . $video_width . '&amp;height=' . $video_height;
							$bb_attribs = 'rel="prettyPhoto"';
						break;

						case 'Shadowbox':
							$bb_class = 'shadowbox';
							$bb_link = 'http://www.youtube.com/v/' . $identifier . '&amp;fs=1&amp;rel=0&amp;autoplay=1';
							$bb_attribs = 'rel="shadowbox;width=' . $video_width . ';height=' . $video_height . ';player=swf"';
						break;
					}

					return '<a href="' . $bb_link . '" class="' . $bb_class . '" ' . $bb_attribs . '><img class="bbvideo_thumb" alt="" title="YouTube Video" src="' . $bb_thumb . '" /></a>';
				}
				// ADD-ON: Open YouTube videos with Lightboxes - END
Replace with:

Code: Select all

				// ADD-ON: Open YouTube videos with Lightboxes - START
				if (($video_name === 'youtube.com' || $video_name === 'youtu.be') && $this->abbcode_config['S_ABBC3_RESIZE'] && in_array($this->abbcode_config['S_ABBC3_RESIZE_METHOD'], array('HighslideBox', 'Lightview', 'prettyPhoto', 'Shadowbox')))
				{
					$identifier = (preg_match($video_data['match'], $in, $matches) ? $matches[1] : '');
					$bb_thumb = 'https://img.youtube.com/vi/' . $identifier . '/2.jpg';

					switch ($this->abbcode_config['S_ABBC3_RESIZE_METHOD'])
					{
						case 'HighslideBox':
							$bb_class = 'highslide';
							$bb_link = 'https://www.youtube.com/embed/' . $identifier . '?rel=0&amp;wmode=transparent&amp;autoplay=1';
							$bb_attribs = 'onclick="return hs.htmlExpand(this, {objectType: \'iframe\', width: ' . $video_width . ', height: ' . $video_height . ', allowSizeReduction: false, wrapperClassName: \'draggable-header no-footer\', numberPosition: null, preserveContent: false, objectLoadTime: \'after\'})"';
						break;

						case 'Lightview':
							$bb_class = 'lightview';
							$bb_link = 'https://www.youtube.com/v/' . $identifier . '&amp;fs=1&amp;rel=0&amp;autoplay=1';
							$bb_attribs = 'rel="flash" title=" :: :: width: ' . $video_width . ', height: ' . $video_height . '"';
						break;

						case 'prettyPhoto':
							$bb_class = 'prettyPhoto';
							$bb_link = 'https://www.youtube.com/watch?v=' . $identifier . '&amp;width=' . $video_width . '&amp;height=' . $video_height;
							$bb_attribs = 'rel="prettyPhoto"';
						break;

						case 'Shadowbox':
							$bb_class = 'shadowbox';
							$bb_link = 'https://www.youtube.com/v/' . $identifier . '&amp;fs=1&amp;rel=0&amp;autoplay=1';
							$bb_attribs = 'rel="shadowbox;width=' . $video_width . ';height=' . $video_height . ';player=swf"';
						break;
					}

					return '<a href="' . $bb_link . '" class="' . $bb_class . '" ' . $bb_attribs . '><img class="bbvideo_thumb" alt="" title="YouTube Video" src="' . $bb_thumb . '" /></a>';
				}
				// ADD-ON: Open YouTube videos with Lightboxes - END
Save the file.

Your https videos will now load in the box style you chose if you have this addon with these new changes.
<!-- IF U_LOVE_NOTEPAD++ -->
[td class=statement]I Notepad++ ![/td]
<!-- ENDNEVER --> <!-- tee hee --> :P
Whoa ooo whoa ooo whoa I'm a Lady!
User avatar
PiperB
Registered User
Posts: 173
Joined: Mon Nov 07, 2016 6:54 pm
Contact: