Display flash videos in the product gallery

Last modified by vinai-kung on Tue, September 23, 2008 01:49
Source|Old Revisions  |  Back To Group

This is an old revision of the document!


Put this into template/catalog/product/gallery.phtml:

  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * @category   design_default
  16. * @package    Mage
  17. * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
  18. * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  19. */
  20. ?>
  21. <?php if ($_isFlash = preg_match('#.flv$#i', $this->getImageFile())): ?>
  22. <?php $_width=470; $_height=320; ?>
  23. <?php else: ?>
  24. <?php $_width=$this->getImageWidth() ?>
  25. <?php endif; ?>
  26. <div style="width:<?php echo $_width; ?>px; margin:0 auto;">
  27.   <div class="a-right"><a href="#" onclick="window.close(); return false;"><?php echo $this->__('Close Window') ?></a></div>
  28.   <div class="a-center">
  29.     <?php if($_prevUrl = $this->getPreviusImageUrl()): ?>
  30.     <a href="<?php echo $_prevUrl ?>" class="product-gallery-nav"><strong>« <?php echo $this->__('Prev') ?></strong></a>
  31.     <?php endif; ?>
  32.     <?php if($_nextUrl = $this->getNextImageUrl()): ?>
  33.     <a href="<?php echo $_nextUrl ?>" class="product-gallery-nav"><strong><?php echo $this->__('Next') ?> »</strong></a>
  34.     <?php endif; ?>
  35.   </div>
  36.   <div class="a-left"><?php echo $this->htmlEscape($this->getCurrentImage()->getLabel()) ?></div>
  37.  
  38.  
  39.  
  40. <?php if($_isFlash): /* -------------------------------- FLASH  DISPLAY --------------------------------- */ ?>
  41.   <div class="clear"></div>
  42. <script type='text/javascript' src='magento/videos/swfobject.js'></script>
  43.  
  44.   <div id='preview'>This div will be replaced
  45.  
  46.   <script type='text/javascript'>
  47.   var s1 = new SWFObject('<?php echo Mage::getUrl() ?>/videos/player.swf','ply','<?php echo $_width ?>','<?php echo $_height ?>','9','#ffffff');
  48.   s1.addParam('allowfullscreen','true');
  49.   s1.addParam('allowscriptaccess','always');
  50.   s1.addParam('wmode','opaque');
  51.   s1.addParam('flashvars','file=<?php echo $this->getImageFile() ?>');
  52.   s1.write('preview');
  53. </script>
  54. </div>
  55.  
  56.  
  57. <?php else: /* -------------------------------- IMAGE  DISPLAY --------------------------------- */ ?>
  58. <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;" />
  59. <?php endif; ?>
  60.  
  61.  
  62.   <div class="a-center">
  63.     <?php if($_prevUrl = $this->getPreviusImageUrl()): ?>
  64.     <a href="<?php echo $_prevUrl ?>" class="product-gallery-nav"><strong>« <?php echo $this->__('Prev') ?></strong></a>
  65.     <?php endif; ?>
  66.     <?php if($_nextUrl = $this->getNextImageUrl()): ?>
  67.     <a href="<?php echo $_nextUrl ?>" class="product-gallery-nav"><strong><?php echo $this->__('Next') ?> »</strong></a>
  68.     <?php endif; ?>
  69.   </div>
  70.   <div class="a-right"><a href="#" onclick="window.close(); return false;"><?php echo $this->__('Close Window') ?></a></div>
  71. </div>
  72. <script type="text/javascript">
  73. Event.observe(window, 'load', function(){
  74. <?php if($_isFlash): ?>
  75.     window.resize(<?php echo $_width ?> +90, <?php echo $_height ?> + 210);
  76. <?php else: ?>
  77.     var dimensions = $('product-gallery-image').getDimensions();
  78.     window.resizeTo(dimensions.width+90, dimensions.height+210);
  79. <?php endif; ?>
  80. });
  81. </script>



 

Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs