当前位置: 首页>>代码示例>>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;未经允许,请勿转载。