News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Ohara YouTube Embed

Started by Suki, December 21, 2011, 03:04:59 PM

Previous topic - Next topic

SDMiller

Quote from: Suki on April 15, 2015, 12:47:11 PM
Try the solution IU gave a couple of messages ago.

Hi Suki,

I tried the solution you gave, specifically:
Quote from: Suki on April 04, 2015, 04:36:29 PMReplace the entire  Themes/default/scripts/ohyoutube.js with this:

and also I did this:

Quote from: Suki on April 05, 2015, 03:35:50 PM
Make sure that your Sources/OharaYTEmbed.php file has this exactly line of code:

... and I still get the same black box which doesn't play on posts using the ohara button, as seen in this example.

Note: the top video box is embedded by admin allowing for html and then using the youtube's embed iframe.
         the bottom black non-working video box is embedded using the ohara button. It's there so you can see it.

In case you're curious, it doesn't matter if ohara is used alone, or following html code, iframe, and cutoff. Its there now at the bottom of that post so that you can take a look at how your code is working (or not working).

The raw code for that post is as follows:


[html]
<p> <iframe width="560" height="315" src="https://www.youtube.com/embed/lbG4ryrsb6w?showinfo=0" frameborder="0" allowfullscreen></iframe> </p>
<p>HUNG HOM, Hong Kong - Hiding under the stairs in the shopping district, in a venue actually called Under the Staircase Shop, works Sister May, who carries on her family's tradition of hand making mahjong tiles in her nestled workshop Kam Fat Mahjong at 2 Bulkeley Street.</p>
<!-- <p><a href="http://www.womenofchina.cn/womenofchina/html1/news/newsmakers/1504/1476-1.htm"><em><img style="float: left;" src="images/stories/various/readmore.png" alt="readmore" /></em></a></p>
<p> </p> -->



[/html][cutoff]

[youtube]https://youtu.be/lbG4ryrsb6w[/youtube]



Any help?

Thanks a bunch. This mod used to work for me, not sure what smf/ohara update broke it.

Thanks again.

^_^

Suki

@SDMiller  Do you have a link where I can see this behavior?


@rtil What  do you mean by blank page?  does it happens on install or any time you access your admin pages?  what php version are you using?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

SDMiller

Quote from: Suki on May 09, 2015, 01:59:46 PM
@SDMiller  Do you have a link where I can see this behavior?

Quote from: SDMiller on May 09, 2015, 12:51:20 AM
... and I still get the same black box which doesn't play on posts using the ohara button, as seen in this example.

Any help?

Thanks a bunch. This mod used to work for me, not sure what smf/ohara update broke it.

Thanks again.

^_^

FLEXjs

I tried to install this mod and broke my forum.

This is the error I get when I try to access it:

Parse error: syntax error, unexpected T_FUNCTION in /home/content/53/9126953/html/forums/Sources/OharaYTEmbed.php on line 28

I uploaded the "removeHooks" file but when I try to access it I get the same error.

How can I fix it please?

margarett

Your PHP version is probably too low to run this MOD.
The best way is to remove the file. Not being there, the hook will fail to load but your forum should load, thus allowing you to finish the removal ;)
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

FLEXjs

OK, I downloaded the "repair_settings.php" and was able to use it to remove all hooks, revert everyone to the default SMF theme, log in, and change it back and uninstall the mod.

Everything seems to be OK now except when I click on the "Admin" button I get this error:

Fatal error: Call to undefined function OYTE_Who() in /home/content/53/9126953/html/forums/Sources/Who.php on line 766

margarett

Edit your Who.php and remove the function call to OYTE_Who ;)

Or attach the file ;)
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

Suki

@SDMiller  Try the solution listed here:

Quote from: Suki on May 07, 2015, 08:33:22 AM

I see where the error is, the .css file only gets uploaded to the default theme but the code is using $settings['theme_url'] which will try to use the current installed theme and not the default one :(

I'll release a fix for this later.  In the meantime you can try this:

Open your Sources/OharaYTEmbed.php and find this:

<link rel="stylesheet" type="text/css" href="'. $settings['theme_url'] .'/css/oharaEmbed.css" />

And replace it with this:

<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url'] .'/css/oharaEmbed.css" />

Its a bug in the mod but I haven't have time to release a new version with the fix.


@FLEXjs  Funny, that function OYTE_Who() is form an old Ohara version, the current version doesn't use that function anymore. That indicates that you might have multiple installs of different versions of this mod.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

SDMiller

Quote from: Suki on May 10, 2015, 10:22:33 PM
@SDMiller  Try the solution listed here:

Quote from: Suki on May 07, 2015, 08:33:22 AM
Open your Sources/OharaYTEmbed.php and find this:

<link rel="stylesheet" type="text/css" href="'. $settings['theme_url'] .'/css/oharaEmbed.css" />

And replace it with this:

<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url'] .'/css/oharaEmbed.css" />


I did that... still doesn't work.

Don't forget I previously did this:

Quote from: Suki on April 04, 2015, 04:36:29 PMReplace the entire  Themes/default/scripts/ohyoutube.js with this:

and I also previously did this:

Quote from: Suki on April 05, 2015, 03:35:50 PM
Make sure that your Sources/OharaYTEmbed.php file has this exactly line of code:

Was I supposed to do the new fix on top of the other two, so ALL THREE manual fixes, or just this latest one all by itself:
<link rel="stylesheet" type="text/css" href="'. $settings['default_theme_url'] .'/css/oharaEmbed.css" />
[/quote]

Thanks for trying to get it working with me.

=)

Suki

Yes, do all those steps.

Now it looks like some other mod added jquery and its using its "no conflict" features which means that the var this mod uses to reference jquery no longer works: $

Can you do another manual fix? besides all the other fixes, open your Themes/default/scripts/ohyoutube.js

find all instances of this: 

$(

and change it for this:

jQuery(

You can do it pretty easily with a code editor like notepad++ actually it will be better to do it with a code editor since doing it manually may result in some instances missed and a single $( missed will prevent the script from working.


Also, the "glossary" mod is using a very outdated version of jquery, that may also be part of the issue.  Might be useful if that mod uses a more recent version.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

FLEXjs

Quote from: Suki on May 10, 2015, 10:22:33 PM

@FLEXjs  Funny, that function OYTE_Who() is form an old Ohara version, the current version doesn't use that function anymore. That indicates that you might have multiple installs of different versions of this mod.

I did have 2 versions installed.  I uninstalled them both and deleted them both but I am still getting that error.

Any idea how to fix?

Thanks.

margarett

Ouch, you should never have 2 versions installed :o

Your best possibility is to check each version's manual installation instructions backwards and make sure that everything is removed...
Manual Installation of Mods
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

SDMiller

Quote from: Suki on May 11, 2015, 10:06:48 AM
find all instances of this: 

$(

and change it for this:

jQuery(

I did that. Still no worky. :(

/*
╩Copyright (c) 2015 Jessica Gonzçlez
╩@license http://www.mozilla.org/MPL/MPL-1.1.html
*/

function oh_main(){

jQuery('.youtube').each(function() {

var videoID = this.id.replace('oh_',''),
imgsrc = oh_getImage(videoID),
imgHeight = jQuery(this).height(),
imgWidth = jQuery(this).width();

if (typeof imgsrc !== 'undefined'){
jQuery(this).css({'background-image': 'url('+ imgsrc +')', 'background-size': 'cover'});
}

jQuery(this).append(jQuery('<div/>', {'class': 'youtube_play'}));

jQuery('#oh_'+videoID).on('click', function() {
var iframe_url = 'https://www.youtube.com/embed/' + videoID + '?autoplay=1&autohide=1';
if (jQuery(this).data('params')) iframe_url+='&'+jQuery(this).data('params');

// The height and width of the iFrame should be the same as parent
var iframe = jQuery('<iframe/>', {'frameborder': '0', 'src': iframe_url, 'width': imgWidth, 'height': imgHeight })

// Replace the YouTube thumbnail with YouTube HTML5 Player
jQuery(this).replaceWith(iframe);
});
});
};

function oh_getImage(youtubeID)
{
var imgsrc = '',
index, len,
imageTypes = ['hqdefault', 'mqdefault', 'sddefault', 'maxresdefault'];
for (index = 0, len = imageTypes.length; index < len; ++index) {
imgsrc = 'http://i.ytimg.com/vi/'+ youtubeID +'/'+ imageTypes[index] +'.jpg';

if (imgsrc.width !=0){
break;
}
}

// Still no image, show the default one
if (imgsrc.width ==0){
imgsrc = 'http://i.ytimg.com/vi/'+ youtubeID +'/default.jpg';
}

return imgsrc;
};

function oh_getUrl(sParam)
{
var sPageURL = window.location.search.substring(1);

// SimpleSEF or pretty urls?
if (sPageURL.indexOf(sParam) > -1) {
return true;
}

var sURLVariables = sPageURL.split(';');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return true;
}
}

return false;
}

function oh_refresh()
{
setTimeout(function(){oh_main()},3E3);
}

jQuery(function(){
oh_main();

if (oh_getUrl('post'))
jQuery('input[name=preview]').on('click',function(){
oh_refresh();
});
});

FLEXjs

Quote from: Suki on May 10, 2015, 10:22:33 PM
@FLEXjs  Funny, that function OYTE_Who() is form an old Ohara version, the current version doesn't use that function anymore. That indicates that you might have multiple installs of different versions of this mod.

So how can I fix because in the package manager it doesn't show any versions as being installed anymore.

Here is the who.php file....

Suki

@SDMiller the glossary mod you have has a very outdated version of jquery that may prevent this mod form working properly.

@FLEXjs  heres the file without the call to that function.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.


SDMiller

Quote from: Suki on May 16, 2015, 01:36:07 PM
@SDMiller the glossary mod you have has a very outdated version of jquery that may prevent this mod form working properly.

Yes, you were quite right. I uninstalled glossary mod (which had to be carefully done manually because it failed almost every test it ran before uninstalling) and now your embed button works as it should.

Which now raises the question.... should I undo this step of your fixes now?
Quote from: Suki on May 11, 2015, 10:06:48 AM
Now it looks like some other mod added jquery and its using its "no conflict" features which means that the var this mod uses to reference jquery no longer works: $

Can you do another manual fix? besides all the other fixes, open your Themes/default/scripts/ohyoutube.js

find all instances of this: 

$(

and change it for this:

jQuery(

I wonder if that step is not only no longer necessary, but may interfere with future checks/find functions.

Thanks for all your support with your mod.

:laugh:

Suki

Well, there was a chance that the glossary mod will have worked with an updated version of jquery, so there was no need to fully uninstall it, just remove the call to the outdated jquery version :P

As for undoing that las change, there is no harm if you leave it as it is or revert it back, that was just a safe call to prevent possible library conflicts.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

FragaCampos

Hi there.
I've tested this mod in localhost and although vimeo videos appear correctly, youtube videos don't. The topic stays normal, but the video doesn't appear (with and without tags).
What may be wrong?

Regards.

Suki

Can you check this new release? https://github.com/MissAllSunday/OharaYouTubeEmbed/releases/tag/v1.2.2

It should solve all the recent issues, the first zip is a ready to load package.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Advertisement: