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?
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.
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.
To be more specific, the individual deleted his own account. We do not typically force delete any accounts other than spammers.
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...
There is this other YouTube BBC mod, better ask it to that author?
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 :)
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?
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. :)
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?)
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.
Thanks man :)
It works nicely.
Great, glad to hear that. :)
@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 (https://github.com/LinuxPanda/SMF2.0Mod--Simple_Youtube_Video_Embedder_BBC_v2), in the event anybody is interested....
If something like this would be included into SMF 2.1, I think you guys should add this too.
at this time we have no plans to add youtube support in 2.1.