Display flash videos in the product gallery
Upload the flash video player JavaScript and SWF to videos/swfobject.js and videos/player.swf (relative to your magento base dir). Then replace the contents of template/catalog/product/gallery.phtml with this code:
- <?php
- /**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-3.0.php
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@magentocommerce.com so we can send you a copy immediately.
- *
- * @category design_default
- * @package Mage
- * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
- ?>
- <?php if ($_isFlash = preg_match('#.flv$#i', $this->getImageFile())): ?>
- <?php $_width=470; $_height=320; ?>
- <?php else: ?>
- <?php $_width=$this->getImageWidth() ?>
- <?php endif; ?>
- <div style="width:<?php echo $_width; ?>px; margin:0 auto;">
- <div class="a-right"><a href="#" onclick="window.close(); return false;"><?php echo $this->__('Close Window') ?></a></div>
- <div class="a-center">
- <?php if($_prevUrl = $this->getPreviusImageUrl()): ?>
- <a href="<?php echo $_prevUrl ?>" class="product-gallery-nav"><strong>« <?php echo $this->__('Prev') ?></strong></a>
- <?php endif; ?>
- <?php if($_nextUrl = $this->getNextImageUrl()): ?>
- <a href="<?php echo $_nextUrl ?>" class="product-gallery-nav"><strong><?php echo $this->__('Next') ?> »</strong></a>
- <?php endif; ?>
- </div>
- <div class="a-left"><?php echo $this->htmlEscape($this->getCurrentImage()->getLabel()) ?></div>
- <?php if($_isFlash): /* -------------------------------- FLASH DISPLAY --------------------------------- */ ?>
- <div class="clear"></div>
- <script type='text/javascript' src='<?php echo Mage::getUrl() ?>/videos/swfobject.js'></script>
- <div id='preview'>This div will be replaced
- <script type='text/javascript'>
- var s1 = new SWFObject('<?php echo Mage::getUrl() ?>/videos/player.swf','ply','<?php echo $_width ?>','<?php echo $_height ?>','9','#ffffff');
- s1.addParam('allowfullscreen','true');
- s1.addParam('allowscriptaccess','always');
- s1.addParam('wmode','opaque');
- s1.addParam('flashvars','file=<?php echo $this->getImageFile() ?>');
- s1.write('preview');
- </script>
- </div>
- <?php else: /* -------------------------------- IMAGE DISPLAY --------------------------------- */ ?>
- <img<?php if($_width): ?> width="<?php echo $_width ?>"<?php endif; ?> src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $this->getImageFile()); ?>" alt="<?php echo $this->htmlEscape($this->getCurrentImage()->getLabel()) ?>" title="<?php echo $this->htmlEscape($this->getCurrentImage()->getLabel()) ?>" id="product-gallery-image" style="display:block;" />
- <?php endif; ?>
- <div class="a-center">
- <?php if($_prevUrl = $this->getPreviusImageUrl()): ?>
- <a href="<?php echo $_prevUrl ?>" class="product-gallery-nav"><strong>« <?php echo $this->__('Prev') ?></strong></a>
- <?php endif; ?>
- <?php if($_nextUrl = $this->getNextImageUrl()): ?>
- <a href="<?php echo $_nextUrl ?>" class="product-gallery-nav"><strong><?php echo $this->__('Next') ?> »</strong></a>
- <?php endif; ?>
- </div>
- <div class="a-right"><a href="#" onclick="window.close(); return false;"><?php echo $this->__('Close Window') ?></a></div>
- </div>
- <script type="text/javascript">
- Event.observe(window, 'load', function(){
- <?php if($_isFlash): ?>
- window.resize(<?php echo $_width ?> +90, <?php echo $_height ?> + 210);
- <?php else: ?>
- var dimensions = $('product-gallery-image').getDimensions();
- window.resizeTo(dimensions.width+90, dimensions.height+210);
- <?php endif; ?>
- });
- </script>

