News:

Wondering if this will always be free?  See why free is better.

Main Menu

Ohara YouTube Embed

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

Previous topic - Next topic

Suki

No, currently there is no setting for that, if you want to align the video to the left, open  your /Sources/OharaYTEmbed.php file, find: style="text-align:center;margin:auto; and change that to your own css.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

simon36

Thanks Suki, I edited the file and it displays the way I want it to now.

katoon123

Any way you can get this to have a popup box to add youtube link and to work when Toggle View is on ; )

natas

excuse my ignorance, but where you say edit ./Sources/Post.php you say find <img> and there are actually two instances of that in the file. do both?

also

database.php
This file should be able to execute standalone.


this seems unclear to me because there are no instructions to upload that file or to do anything with it at all except make sure it is able to execute standalone?

any help would be appreciated.

thanks.

Suki

Welcome to SMF.

Yes, replace the 2 instance of <img>

If you are installing this manually then upload the database.php file to your forlder root and call it with your browser:  mysite.com/forum/database.php

For istalling mods it is always better to use the Package Manager
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

natas

Thanks for the reply and thanks for the mod.

Grimster

Thanks for a great mod Suki  ;D

dzoni22

I have a problem with smiles after youtbe video, too.

Everything is OK before video but after video forum shows me a code instead of smiley.
After second youtube video show smiley again, no code.  ???

Suki

It's been reported before, don't have the time right now to check/fix, must be something in the bbc and/or how is presented.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Forces of Steel

Uhh I downloaded this package, the latest version, from the mod site and then uploaded to my forum which uses SMF 2.0.2, and the mod doesn't work. The button to insert a video doesn't appear, and the BB code also doesn't function at all. Did I miss something? I installed it via the package manager upload feature.

BigMike

Hello SMF,

Suki, thank you for this nice mod. I've been using it now since earlier this year. I've been wanting the videos to display similar to a vBulletin format, so I made some changes including listing the video's Title and link to watch on YouTube if the user so desires.

Here are the changes I made:

File: OharaYTEmbed.php & function OYTE_Replace()

Original lines 131-139:
$height = empty($modSettings['OYTE_video_height']) ? '315' : $modSettings['OYTE_video_height'];

/* Return the HTML  */
$return = '
<div style="text-align:center;margin:auto;padding:5px;" class="youtube '.$string.'">
<iframe width="'.$width.'" height="'.$height.'" src="http://www.youtube.com/embed/'.$string.'" frameborder="0"></iframe>
</div>';

return $return;


New lines starting from the same line 131 and ending with the same return statement. I added notes to show what is going on:

$height = empty($modSettings['OYTE_video_height']) ? '315' : $modSettings['OYTE_video_height'];

    // This grabs the video info
    $videoinfo = file_get_contents("http://www.youtube.com/oembed?url=http%3A//youtube.com/watch%3Fv%3D".$string."&format=json");
    // Position where the Video's Title begins
    $pos_start = 10 + strpos($videoinfo, '"title": "');
    // Position where the Video's Title ends
    $pos_end = strpos($videoinfo, '", "html":');
    // The length of the Title
    $pos_length = $pos_end - $pos_start; 
    // Pulls only the Title from the video info
    $video_title = substr($videoinfo, $pos_start, $pos_length);
    // Trim the Title if it is longer than 50 characters
    if ($pos_length > 50)
      $video_title = substr($video_title,0,50) . '...';

    // I am using the old display method that includes the video controls. Replace the <object></object> bit with the newer YouTube iFrame method if desired   
    // I set the title's link to open in a new tab. This is not how vB does it, but I prefer it this way.
    $return = '
<span>
  <div style="text-align: center;">
    <table width="' . $width . '" cellspacing="2" cellpadding="0" align="center" style="margin: auto; border: 1px solid #9999AA;">
      <tbody>
        <tr>
          <td width="' . $width . '"><h3 class="catbg" style="font-weight: normal;"><a href="http://www.youtube.com/watch?v=' . $string . '" target="_blank">YouTube - ' . $video_title . '</a></h3></td>
        </tr>
        <tr height="400">
          <td style="background: none repeat scroll 0 0 #000000; line-height: 0;">
            <object width="' . $width . '" height="' . $height . '">
              <param name="movie" value="http://www.youtube.com/v/' . $string . '&rel=0&hl=en_US&feature=player_embedded&version=1"></param>
              <param name="allowFullScreen" value="true"></param>
              <param name="allowScriptAccess" value="always"></param>
              <embed src="http://www.youtube.com/v/' . $string . '&rel=0&hl=en_US&feature=player_embedded&version=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="' . $width . '" height="' . $height . '"></embed>
            </object>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</span>';

return $return;


Notes:
  • For theming, I am using SMF's own catbg h3 style to match the forum's existing headers.
  • I am using a thin border of color #9999AA which you'd want to change to match your forum as needed.
  • Trimming the title at 50 characters works for me (I am using a larger than default video size), so also change this trim number as desired to go along with your own video width.

Here are some screen shots. Click for full size image...

Original method:
         

New method:


...and a link to the new method to see it in action:
http://board.marlincrawler.com/index.php?topic=6532.msg1024256#msg1024256

If someone out there has been trying to get the Video's Title to display then I hope this helps!

Thanks again for this awesome mod!! :D :D

Regards,
BigMike

Suki

YouTube has an API where you can get all info from a video, you just need to pass the video ID, I wanted to include that API on this mod but unfortunately I haven't had the time to do so.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

BigMike

Quote from: Suki on August 31, 2012, 02:56:51 PM
YouTube has an API where you can get all info from a video, you just need to pass the video ID, I wanted to include that API on this mod but unfortunately I haven't had the time to do so.
[ace ventura]Ohhh reeeheeeeeheeeeheeeeaaaaaaalllllllllllllllly[/ace ventura]

I figured they did so I searched Google for it but only came up with a bunch of wget and server options, so I went with the file_get_contents() method and then did the dirty work. The API would have made this so simple I probably wouldn't have posted up my How-To :-|

Thanks again for the mod, we really like it! Another step would be to parse different YT parameters such as if a "feature=related" is placed in front of the video ID, at least on my site this brakes the pattern matching.

Keep it up!!

Regards,
BigMike

Suki

Is not that difficult to implement and its actually far more easy to manipulate than fetching a whole webpage. The API does provide a lot of info, including the video title.

If I have the time I would change this so every video doesn't get loaded within the page but just show the link or the image preview, when click it, load the video.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Kurogane

I've a problem with this mod everything is working but some reason i can't see the youtube image in the editor.

Suki

uninstall it and then install it again, when installing, scroll down and click on the "install on other themes"  checkbox.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Kurogane

Already did multiple times and still not working in my other template or default theme.

Suki

Make sure the youtube.gif image is already stored on your  Themes/your_theme/images/bbc/ directory


where your_theme is the actual name of the theme you are using.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Kurogane

Is not the image mark not found if not the fuction is not added subs.php.

Here screenshot


Suki

The mod doesn't modify Subs.php at all, the mod sues it's own file: OharaYTEmbed.php

Make sure the following code is presented on that file:


/* The bbc button */
function OYTE_bbc_add_button($buttons)
{
global $txt, $modSettings;

loadLanguage('OharaYTEmbed');

if (empty($modSettings['OYTE_master']))
return;

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


If there is, try to change this:

function OYTE_bbc_add_button($buttons)

with this:

function OYTE_bbc_add_button(&$buttons)
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Advertisement: