Yet Another YouTube BBCode Tag

Started by dougiefresh, December 10, 2014, 06:09:01 PM

Previous topic - Next topic

JaGuR

Quote from: dougiefresh on May 13, 2015, 04:56:08 PM
Uploaded v2.5 - April 13th, 2015
o Fixed mistake introduced in v2.4 regarding YouTube links.

Quote from: Sapozhnik on May 13, 2015, 02:27:15 AM
You inserted 'embed' twice  (original link: http://www.youtube.com/watch?v=Hu3LdtU9-l4):
@Sapozhnik:  WHOOPS!!!  Damn, I can't believe I missed that....  This update fixes this problem...

Quote from: Gryzor on May 13, 2015, 03:03:06 AM
Only problem I've found: in Firefox (37, 38 at least) if you press the BB button without having selected any text, it only inserts the opening tag...
@Gryzor:  I can't reproduce this report.  On a clean forum copy, the YouTube button inserts the tags just fine....

I was having the same issue, seems to have something to do with the "toggle view" button in the wysiwig editor :(

Spent about two hours trying to figure out why the custom bbcode mod wasn't working properly, had the same issue of not closing the tags.

When I saw your post after installing the youtube mod, I realised I had been playing the the toggle view button, not knowing what it actually did.

seems it stuffs the bbcode buttons :(

Gryzor


dougiefresh

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".


dougiefresh

UPDATE: Yesterday, I was notified of a potentially "fatal flaw" in SMF's bbcode parser function.  The parser generates an array with all possible permutations of the parameters, and thus can run out of memory when dealing with a bbcode tag with a large number of parameters.  I've solved this problem in my Post and PM Inline Attachments mod, and I'm going to attempt to solve it for this mod as well....  It's a little more complicated because of the "alt" parameter in the mess of things....

dougiefresh

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

spijker46

First of all, I'd like to compliment you with the hard work you provide. Well done!

Now my question . I use the plugin on my website where I find it very annoying that use videos 100 % of the available space . Now I understand that this is manually updated by specifying the height and width. Only then Tapatalk not understand this and let the videos do not see anymore.

Is there a possibility , from the code itself to adjust it manually, and if so , where should I look for it in that case?

I'm curious about your reaction .

Keep up the good work!

dougiefresh

Use something like this:
[youtube width=640 width=480]{url goes here}[/youtube]
That SHOULD (and hopefully) solves your problem.

spijker46

Do you mean I should change that here:

function BBCode_YouTube_Button(&$buttons)
{
        global $txt;

        $buttons[count($buttons) - 1][] = array(
                'image' => 'youtube',
                'code' => 'youtube',
                'description' => $txt['youtube'],
                'before' => '[youtube]',
                'after' => '[/youtube]',
        );
}


Or should I change it somewhere else in the code?

The above part I allready tried. It does work, but the output in the messages will be something like you recommend: [youtube width=640 width=480]{url goes here}[/youtube]
In my forum, you see the vids at width: 640 and height: 480, but in Tapatalk you still see: [youtube width=640 width=480]{url goes here}[/youtube] ;)

What I am looking for is to show in the messages on my forum:
whereby in the code somewhere the 100% is changed to : [youtube width=640 width=480]{url goes here}[/youtube]

I hope you do understand me :-)

spijker46

What I mean to say , I would like the default which is now at 100% of the code , want to put on a default of 640/480 .
In the message on the forum should be thus shown: [ youtube] { url} [/ youtube] Tapatalk so that it can handle . :-)

dougiefresh

Oh, I understand what you are asking now.  In Subs-BBCode-YouTube.php, you should change this:
Code (Find) Select
'before' => '[youtube]',
to this:
Code (Replace) Select
'before' => '[youtube width=640 height=480]',
Hopefully, that'll do what you need....

spijker46

Quote from: dougiefresh on August 04, 2015, 04:24:34 AM
Oh, I understand what you are asking now.  In Subs-BBCode-YouTube.php, you should change this:
Code (Find) Select
'before' => '[youtube]',
to this:
Code (Replace) Select
'before' => '[youtube width=640 height=480]',
Hopefully, that'll do what you need....

Thanks for the reply. I have tried to change that, but it didn't work out for me. In the forum in my browser on the PC it does work now, but in Tapatalk it still doesn't.

But!!!

I have looked further in the code of Subs-BBCode-YouTube.php and I found the next setting:


        // Set width or height with respect to aspect ratio if just one is set.  Set both if neither:
        if (!isset($context['bbc_youtube']['width']) && isset($context['bbc_youtube']['height']))
                $context['bbc_youtube']['width'] = floor($context['bbc_youtube']['height'] * 1.6);
        elseif (isset($context['bbc_youtube']['width']) && !isset($context['bbc_youtube']['height']))
                $context['bbc_youtube']['height'] = floor($context['bbc_youtube']['width'] * 0.625);
        $width = (isset($context['bbc_youtube']['width']) ? $context['bbc_youtube']['width'] : 0);
        $height = (isset($context['bbc_youtube']['height']) ? $context['bbc_youtube']['height'] : 0);


Whereby I changed the last two lines into:


        $width = (isset($context['bbc_youtube']['width']) ? $context['bbc_youtube']['width'] : 640);
        $height = (isset($context['bbc_youtube']['height']) ? $context['bbc_youtube']['height'] : 480);


And now it does work! :-) Thanks for thinking and pointing me to the right direction.

-edit-
The problem with Tapatalk (app for android/iphone); it does understand code like:
[youtube]{ur}[/youtube]
but it doesnt understand code like:
[youtube width=640 height=480]{ur}[/youtube]

Now with the change I made, the mainly code still remains:
[youtube]{ur}[/youtube]
so Tapatalk still understands :)


Like I said before, keep up the good work! :)

dougiefresh

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

Gryzor

This is an awesome mod, however for some reason some videos lately have started appearing huge.

Since my users probably won't go to any lengths to set the height and width of the video manually, could there be a setting for the default size? Supposedly the default is 640x480 but it doesn't always work...

dougiefresh

I can do one of two things.  I can make the mod respect the maximum image size specified in the admin area, or make a completely new setting under Modifications for this new setting.  The first option would be easiest, but the second wouldn't be much more difficult....  Any opinions?

Btw, I still have to work through Thursday, and my wife and I have stuff planned for Friday.  My computer is also getting repaired this weekend (Fri/Sat), so it may not be "fixed" this week....

Gryzor

Hello mate,

Thanks for getting back.

Having a separate setting would be much preferred; on my forum, for instance, we discuss hardware so sometimes we post large photos (large zoom factors) of boards, components etc, so the same limit for photos and videos would not be practical.

But that's my 2 cents. Do take your time :) I can maybe roll back for the time being!

dougiefresh

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.

Gryzor

Oh man, you rule! Just installed, did a test, worked perfectly. Thanks so much :)

Gryzor

I think YT may have changed something. Now, most (if not all?) my videos have a "! No longer available" beneath them... the vids show fine though.

dougiefresh

Quote from: Gryzor on August 21, 2015, 05:29:18 AM
I think YT may have changed something. Now, most (if not all?) my videos have a "! No longer available" beneath them... the vids show fine though.
Link, please!  I just looked at my localhost forum with this mod installed and am not seeing that message....

Gryzor

Nah, Aeva was probably messing it up, I think it's fine after I removed it... thanks!

Advertisement: