当前位置: 首页>>代码示例>>PHP>>正文


PHP FileHelper::getMimeType方法代码示例

本文整理汇总了PHP中FileHelper::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHelper::getMimeType方法的具体用法?PHP FileHelper::getMimeType怎么用?PHP FileHelper::getMimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileHelper的用法示例。


在下文中一共展示了FileHelper::getMimeType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getWidgetIconSvg

 /**
  * Returns a widget type’s SVG icon.
  *
  * @param IWidget $widgetType
  *
  * @return string
  */
 private function _getWidgetIconSvg(IWidget $widgetType)
 {
     $iconPath = $widgetType->getIconPath();
     if ($iconPath && IOHelper::fileExists($iconPath) && FileHelper::getMimeType($iconPath) == 'image/svg+xml') {
         return IOHelper::getFileContents($iconPath);
     }
     return craft()->templates->render('_includes/defaulticon.svg', array('label' => $widgetType->getName()));
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:15,代码来源:DashboardController.php

示例2: getMimeType

 /**
  * If the path points to a real file, we call {@link FileHelper::getMimeType()}, otherwise
  * {@link FileHelper::getMimeTypeByExtension()}
  *
  * @param string $path The path to test.
  *
  * @return string The mime type.
  */
 public static function getMimeType($path)
 {
     if (@file_exists($path)) {
         return FileHelper::getMimeType($path);
     } else {
         return FileHelper::getMimeTypeByExtension($path);
     }
 }
开发者ID:paulcarvill,项目名称:Convergence-craft,代码行数:16,代码来源:IOHelper.php

示例3: loadImage

 /**
  * Loads an image from a file system path.
  *
  * @param string $path
  *
  * @throws Exception
  * @return Image
  */
 public function loadImage($path)
 {
     if (!IOHelper::fileExists($path)) {
         throw new Exception(Craft::t('No file exists at the path “{path}”', array('path' => $path)));
     }
     if (!craft()->images->checkMemoryForImage($path)) {
         throw new Exception(Craft::t("Not enough memory available to perform this image operation."));
     }
     // Make sure the image says it's an image
     $mimeType = FileHelper::getMimeType($path, null, false);
     if ($mimeType !== null && strncmp($mimeType, 'image/', 6) !== 0) {
         throw new Exception(Craft::t('The file “{path}” does not appear to be an image.', array('path' => $path)));
     }
     try {
         $this->_image = $this->_instance->open($path);
     } catch (\Exception $exception) {
         throw new Exception(Craft::t('The file “{path}” does not appear to be an image.', array('path' => $path)));
     }
     // If we're using Imagick _and_ one that supports it, convert CMYK to RGB, save and re-open.
     if (!craft()->images->isGd() && $this->_image->getImagick()->getImageColorspace() == \Imagick::COLORSPACE_CMYK && method_exists($this->_image->getImagick(), 'transformimagecolorspace')) {
         $this->_image->getImagick()->transformimagecolorspace(\Imagick::COLORSPACE_SRGB);
         $this->_image->save();
         return craft()->images->loadImage($path);
     }
     $this->_imageSourcePath = $path;
     $this->_extension = IOHelper::getExtension($path);
     if ($this->_extension == 'gif') {
         if (!craft()->images->isGd() && $this->_image->layers()) {
             $this->_isAnimatedGif = true;
         }
     }
     $this->_resizeHeight = $this->getHeight();
     $this->_resizeWidth = $this->getWidth();
     return $this;
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:43,代码来源:Image.php

示例4: testDetectsCorrectMimeTypeUsingMagicNumbersAndFallingBackToExtensionLookupForSwf

 public function testDetectsCorrectMimeTypeUsingMagicNumbersAndFallingBackToExtensionLookupForSwf()
 {
     $pathToFile = dirname(__FILE__) . '/../../../../../resources/test.swf';
     $this->assertEquals('application/x-shockwave-flash', FileHelper::getMimeType($pathToFile));
 }
开发者ID:boxuk,项目名称:describr,代码行数:5,代码来源:FileHelperTest.php


注:本文中的FileHelper::getMimeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。