Common Recipes

From TubePress Documentation
Jump to: navigation, search


This page describes how to accomplish a few frequently-asked customizations

Contents

Remove Title from Embedded Video Player

This modification removes the "large" title that displays above the embedded video player when using the normal player location.



  1. If you haven't already, create and activate a custom TubePress theme. This will protect your edits when TubePress is upgraded.

  2. Change your theme's copy of players/normal.tpl.php from:
    <div class="tubepress_normal_embedded_wrapper" style="width: <?php echo ${tubepress_api_const_template_Variable::EMBEDDED_WIDTH}; ?>px">
     
        <div id="tubepress_embedded_title_<?php echo ${tubepress_api_const_template_Variable::GALLERY_ID}; ?>" class="tubepress_embedded_title">
          <?php echo ${tubepress_api_const_template_Variable::VIDEO}->getTitle(); ?>
     
        </div>
        <div id="tubepress_embedded_object_<?php echo ${tubepress_api_const_template_Variable::GALLERY_ID}; ?>">
          <?php echo ${tubepress_api_const_template_Variable::EMBEDDED_SOURCE}; ?>
     
        </div>
    </div>

    to

    <div class="tubepress_normal_embedded_wrapper" style="width: <?php echo ${tubepress_api_const_template_Variable::EMBEDDED_WIDTH}; ?>px">
     
        <div id="tubepress_embedded_object_<?php echo ${tubepress_api_const_template_Variable::GALLERY_ID}; ?>">
          <?php echo ${tubepress_api_const_template_Variable::EMBEDDED_SOURCE}; ?>
     
        </div>
    </div>

That's it!

Hide All Thumbnails for a Gallery

This customization can be useful in a few scenarios. It will hide all thumbnails for a gallery, but leave the embedded video player shown. On page load, the embedded video player will be loaded with the first video in the gallery.

  1. If you haven't already, create and activate a custom TubePress theme. This will protect your edits when TubePress is upgraded.

  2. In your theme's copy of gallery.tpl.php, you'll want to simply delete everything related to the display of the thumbnails. That's the bulk of the template, so afterwards your theme's gallery.tpl.php should have only the following contents:
    <div class="tubepress_container" id="tubepress_gallery_<?php echo ${org_tubepress_api_const_template_Variable::GALLERY_ID}; ?>">
     
        <?php echo ${org_tubepress_api_const_template_Variable::PLAYER_HTML}; ?>
     
    </div>

That's it!

Optimize Load-Time Performance

In order to operate normally, TubePress will make network connections to YouTube or Vimeo. This server-side operation can, even in optimal network conditions, be devastating to the load-time performance of your website. Thankfully, today there are dozens of tools and libraries that can assist site owners in significantly speeding up their sites.

The rest of this section lists of a few of our favorite measurement and optimization tools, tailored to your environment.

All Sites

  1. Use a PHP accelerator
     
    There is virtually no reason not to use a PHP accelerator (a.k.a. "opcode cache"). Any one of the available accelerators will provide a free, and huge, speed boost for any PHP-powered website. Check with your hosting provider to ensure that your PHP installation is running an accelerator.
     
  2. Sign up for CloudFlare's free plan
     
    We'd be hard pressed to come up with a reason not to use CloudFlare. Even their free plan can dramatically improve the load time of your site, with virtually no changes to your site's configuration.
     
  3. Use Yahoo!'s YSlow tool.
     
    This is a free add-on for browsers that can pinpoint performance bottlenecks in your site. It's easy to install, simple to use, and Yahoo! provides a great explanation of YSlow's recommendations.
     
  4. Get in the habit of regularly running WebPagetest
     
    This is a very powerful, and free!, web-based tool that uses metrics similar to those of YSlow. It's easy to use and provides sage advice.
     
  5. Consider your hosting provider
     
    Sadly, shared hosting is going the way of the dinosaurs. You simply cannot achieve maximum performance if you are running your site on a shared host. Here are a few PHP PaaS providers that we like (in no particular order):
     
    1. Pagoda Box
    2. Amazon's Elastic Beanstalk
    3. AppFog
    4. Orchestra
    5. cloudControl (currently Europe-only)

WordPress

  1. Use a caching plugin like W3TC or WP Super Cache
     
    Much like CloudFlare, it's nearly inexcusable to run WordPress without a caching plugin. WordPress is powerful, but without any help it moves at the speed of a tank. Properly installed and configured, a caching plugin can improve your site's performance by a factor of ten (probably much more!).

Standalone PHP

  1. Enable TubePress's API Cache
     
    TubePress implements a basic API cache that you can configure via TubePress name-value pairs. This cache requires a writable directory on your filesystem, and in the absence of other caching tools can provide a dramatic performance boost.
     
  2. Implement server-side caching
     
    The topic of server-side caches is far too complex to discuss here, but here are some of our favorite caching tools/libraries (in no particular order!)
    1. Varnish
    2. memcached
    3. squid
    4. Alternative PHP Cache (APC)
    5. Stash

Remove Scrollbars from Shadowbox.js

An out-of-the-box Shadowbox.js installation will work beautifully on most websites. However, some sites will show pesky scrollbars on the video. The solution to this just takes a small edit to Shadowbox.js's CSS.

Change line 8 of lib/shadowbox.css from

#sb-player.html{height:100%;overflow:auto;}

to

#sb-player.html{height:100%;overflow:hidden;}
Personal tools
Namespaces

Variants
Views
Actions
Navigation
Overview
Getting Started
Usage
Options Reference
Customizing
Troubleshooting
Toolbox