當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MediaInterface::getBox方法代碼示例

本文整理匯總了PHP中Sonata\MediaBundle\Model\MediaInterface::getBox方法的典型用法代碼示例。如果您正苦於以下問題:PHP MediaInterface::getBox方法的具體用法?PHP MediaInterface::getBox怎麽用?PHP MediaInterface::getBox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sonata\MediaBundle\Model\MediaInterface的用法示例。


在下文中一共展示了MediaInterface::getBox方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getBox

 /**
  * {@inheritdoc}
  */
 public function getBox(MediaInterface $media, array $settings)
 {
     $size = $media->getBox();
     $skipBox = false;
     $constraint = array_key_exists('constraint', $settings) && $settings['constraint'] === false;
     if ($constraint && $size->getHeight() > $size->getWidth()) {
         $settings['width'] = $settings['height'];
         $this->mode = ImageInterface::THUMBNAIL_INSET;
         $skipBox = true;
     }
     $hasWidth = array_key_exists('width', $settings) && $settings['width'] > 0;
     $hasHeight = array_key_exists('height', $settings) && $settings['height'] > 0;
     if (!$hasWidth && !$hasHeight) {
         throw new \RuntimeException(sprintf('Width/Height parameter is missing in context "%s" for provider "%s". Please add at least one parameter.', $media->getContext(), $media->getProviderName()));
     }
     if ($hasWidth && $hasHeight && !$skipBox) {
         return new Box($settings['width'], $settings['height']);
     }
     if (!$hasHeight) {
         $settings['height'] = (int) ($settings['width'] * $size->getHeight() / $size->getWidth());
     }
     if (!$hasWidth) {
         $settings['width'] = (int) ($settings['height'] * $size->getWidth() / $size->getHeight());
     }
     return $this->computeBox($size, $settings);
 }
開發者ID:zapoyok,項目名稱:core-bundle,代碼行數:29,代碼來源:ScaleCropResizer.php

示例2: getHelperProperties

 /**
  * {@inheritdoc}
  */
 public function getHelperProperties(MediaInterface $media, $format, $options = array())
 {
     if ($format == 'reference') {
         $box = $media->getBox();
     } else {
         $resizerFormat = $this->getFormat($format);
         if ($resizerFormat === false) {
             throw new \RuntimeException(sprintf('The image format "%s" is not defined.
                     Is the format registered in your ``sonata_media`` configuration?', $format));
         }
         $box = $this->resizer->getBox($media, $resizerFormat);
     }
     return array_merge(array('alt' => $media->getName(), 'title' => $media->getName(), 'src' => $this->generatePublicUrl($media, $format), 'width' => $box->getWidth(), 'height' => $box->getHeight()), $options);
 }
開發者ID:ingeniorweb,項目名稱:symfo3cv,代碼行數:17,代碼來源:ImageProvider.php

示例3: computeBox

 /**
  * @throws InvalidArgumentException
  *
  * @param MediaInterface $media
  * @param array          $settings
  *
  * @return Box
  */
 protected function computeBox(MediaInterface $media, array $settings)
 {
     if ($this->mode !== ImageInterface::THUMBNAIL_INSET && $this->mode !== ImageInterface::THUMBNAIL_OUTBOUND) {
         throw new InvalidArgumentException('Invalid mode specified');
     }
     $size = $media->getBox();
     $ratios = array($settings['width'] / $size->getWidth(), $settings['height'] / $size->getHeight());
     if ($this->mode === ImageInterface::THUMBNAIL_INSET) {
         $ratio = min($ratios);
     } else {
         $ratio = max($ratios);
     }
     return $size->scale($ratio);
 }
開發者ID:Infernosquad,項目名稱:SonataMediaBundle,代碼行數:22,代碼來源:SimpleResizer.php

示例4: getHelperProperties

 /**
  * {@inheritdoc}
  */
 public function getHelperProperties(MediaInterface $media, $format, $options = array())
 {
     if ($format == 'reference') {
         $box = $media->getBox();
     } else {
         $resizerFormat = $this->getFormat($format);
         if ($resizerFormat === false) {
             throw new \RuntimeException(sprintf('The image format "%s" is not defined.
                     Is the format registered in your ``sonata_media`` configuration?', $format));
         }
         $box = $this->resizer->getBox($media, $resizerFormat);
     }
     $properties = array_merge(array('poster' => $this->generatePublicUrl($media, $this->getFormatName($media, 'wide_big')), 'alt' => $media->getName(), 'title' => $media->getName(), 'src' => $this->generatePublicUrl($media, $format), 'width' => $box->getWidth(), 'height' => $box->getHeight(), 'type' => $media->getContentType(), 'controls' => true, 'autoplay' => true, 'loop' => false, 'width' => '"100%"', 'height' => 100, 'waveColor' => 'red', 'progressColor' => 'blue', 'cursorColor' => 'green'), $options);
     return $properties;
 }
開發者ID:NadirZenith,項目名稱:NzSonataMediaBundle,代碼行數:18,代碼來源:AudioProvider.php

示例5: getBox

 /**
  * {@inheritdoc}
  */
 public function getBox(MediaInterface $media, array $settings)
 {
     $size = $media->getBox();
     if (null != $settings['height']) {
         if ($size->getHeight() > $size->getWidth()) {
             $higher = $size->getHeight();
             $lower = $size->getWidth();
         } else {
             $higher = $size->getWidth();
             $lower = $size->getHeight();
         }
         if ($higher - $lower > 0) {
             return new Box($lower, $lower);
         }
     }
     $settings['height'] = (int) ($settings['width'] * $size->getHeight() / $size->getWidth());
     if ($settings['height'] < $size->getHeight() && $settings['width'] < $size->getWidth()) {
         return new Box($settings['width'], $settings['height']);
     }
     return $size;
 }
開發者ID:ingeniorweb,項目名稱:symfo3cv,代碼行數:24,代碼來源:SquareResizer.php

示例6: dummyCompute

 public function dummyCompute(MediaInterface $media, array $settings)
 {
     $size = $media->getBox();
     return $this->computeBox($size, $settings);
 }
開發者ID:zapoyok,項目名稱:core-bundle,代碼行數:5,代碼來源:ScaleCropResizerTest.php

示例7: getBoxHelperProperties

 /**
  * @param \Sonata\MediaBundle\Model\MediaInterface $media
  * @param string                                   $format
  * @param array                                    $options
  *
  * @return \Imagine\Image\Box
  */
 protected function getBoxHelperProperties(MediaInterface $media, $format, $options = array())
 {
     if ($format == 'reference') {
         return $media->getBox();
     }
     if (isset($options['width']) || isset($options['height'])) {
         $settings = array('width' => isset($options['width']) ? $options['width'] : null, 'height' => isset($options['height']) ? $options['height'] : null);
     } else {
         $settings = $this->getFormat($format);
     }
     return $this->resizer->getBox($media, $settings);
 }
開發者ID:novatex,項目名稱:SonataMediaBundle,代碼行數:19,代碼來源:BaseVideoProvider.php

示例8: getBox

 /**
  * {@inheritdoc}
  */
 public function getBox(MediaInterface $media, array $settings)
 {
     $size = $media->getBox();
     if ($settings['width'] === null && $settings['height'] === null) {
         $settings['width'] = $size->getWidth();
         $settings['height'] = $size->getHeight();
     }
     if ($settings['height'] === null) {
         $settings['height'] = (int) ($settings['width'] * $size->getHeight() / $size->getWidth());
     }
     if ($settings['width'] === null) {
         $settings['width'] = (int) ($settings['height'] * $size->getWidth() / $size->getHeight());
     }
     return new Box($settings['width'], $settings['height']);
 }
開發者ID:elom5000,項目名稱:BardisCMS,代碼行數:18,代碼來源:BardisCMSResizer.php


注:本文中的Sonata\MediaBundle\Model\MediaInterface::getBox方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。