Adding option to stop mod from displaying YouTube video's as a video

Started by NekoJonez, May 11, 2014, 06:42:27 AM

Previous topic - Next topic

NekoJonez

Okay, the title might need some explanation.

I'm using the "Simple Youtube Video Embedder/BBC" mod to render my YouTube video's as a video directly on my forum. (Sadly enough, I don't find it anymore on the mod site. Am I looking wrong?)

Anyways, some of my users have a slow connection and the loading of all those video's make it that their computer has a sort of mini heart attack.

But the users don't want the feature to go away.

Now my question is, how can I add some code where users can toggle an option that makes it that YouTube vids don't render as a video but stay as a link?

Is that possible or not?
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Kindred

Well. Without looking at the mod specific code, it's hard to say...  You really would need to ask the mod author.

Also, adding a per user setting can be tricky... Since you have to store it in the database.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

br360

Quote from: NekoJonez on May 11, 2014, 06:42:27 AM

I'm using the "Simple Youtube Video Embedder/BBC" mod to render my YouTube video's as a video directly on my forum. (Sadly enough, I don't find it anymore on the mod site. Am I looking wrong?)

It looks like the person that wrote the mod had his account deleted; and all of his mods were removed from here as well.

Kindred

To be more specific, the individual deleted his own account. We do not typically force delete any accounts other than spammers.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

margarett

It should be possible to change the bbc parsing so that it opts to add the iframe or not, depending on a user setting.
But that requires a new field to be added in profile. There are other similar mods around, maybe you can poke on of the authors and see what do they have to say...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

NekoJonez

There is this other YouTube BBC mod, better ask it to that author?
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

margarett

Just YouTube I'm not sure. But there are for sure other auto-embedders ;)

In any case, all of them (IIRC) always embed the content. What you need is a "simple" switch to either embed it not, depending on the user setting... And that's the laborious task, really :)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

NekoJonez

So, what should I do next?

Also, the current mod I have uses tags to embed the vids. We just need to post a link and it displays like a vid. Should I change anything about that?
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Kays

Actually, adding to $options isn't that big a deal. And it is possible to disable a bbc tag.

However when I tested this on Suki's mod all that I got was the video id number. Which was not quite what I expected. ::)

Here's a quick test to see what will happen if the [youtube] tag is disabled with the mod you are using. In Subs.php look for:


if ($smileys === 'print')


And add the following before that


if (!empty($context['user']['is_admin']))
$disabled['youtube'] = true;


Then go and view a post with video in it. If it's now a link, then there's hope. :)

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

NekoJonez

Yes, it works perfectly. :) But now, how can I add this as an option for users?
(And if possible, if that option is check, that the Youtube url is seen as a link?)
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Kays

Cool, I just wanted to verify that you do get a link before getting you to make the code changes. :)

Now replace that code in Subs.php with the following:


// Added to allow the user the option to not embed a YouTube video
global $options;
if (!empty($options['no_embed_youtube']))
$disabled['youtube'] = true;


In Profile.template.php in your theme or the one in the default theme if there isn't one in the theme you are using. Look for:


// Choose WYSIWYG settings?


Add before that:


// Added to allow the user the option to not embed a YouTube video
echo '
<li>
<input type="hidden" name="default_options[no_embed_youtube]" value="0" />
<label for="no_embed_youtube"><input type="checkbox" name="default_options[no_embed_youtube]" id="no_embed_youtube" value="1"', !empty($context['member']['options']['no_embed_youtube']) ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['no_embed_youtube'], '</label>
</li>';


Finally, add the following to Modifications.english.php before the closing ?>


$txt['no_embed_youtube'] = 'Show YouTube videos as a link.';


If not using English for your language, translate that and add it to the Modifications file for your language.

This option now can be found on the "Look and layout" area in the user's profile.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

NekoJonez

Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Kays


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

dougiefresh

@Kays: Thanks for the helpful information regarding how to make that mod show a link instead of a video....

Quote from: NekoJonez on May 11, 2014, 06:42:27 AM
I'm using the "Simple Youtube Video Embedder/BBC" mod to render my YouTube video's as a video directly on my forum. (Sadly enough, I don't find it anymore on the mod site. Am I looking wrong?)
I found the mod at GitHub, in the event anybody is interested....

NekoJonez

If something like this would be included into SMF 2.1, I think you guys should add this too.
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Illori

at this time we have no plans to add youtube support in 2.1.

Advertisement: