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


PHP MimeMagic::improveTypeFromExtension方法代碼示例

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


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

示例1: getPropsFromPath

 /**
  * Get an associative array containing information about
  * a file with the given storage path.
  *
  * Resulting array fields include:
  *   - fileExists
  *   - size (filesize in bytes)
  *   - mime (as major/minor)
  *   - media_type (value to be used with the MEDIATYPE_xxx constants)
  *   - metadata (handler specific)
  *   - sha1 (in base 36)
  *   - width
  *   - height
  *   - bits (bitrate)
  *   - file-mime
  *   - major_mime
  *   - minor_mime
  *
  * @param string $path Filesystem path to a file
  * @param string|bool $ext The file extension, or true to extract it from the filename.
  *             Set it to false to ignore the extension.
  * @return array
  * @since 1.28
  */
 public function getPropsFromPath($path, $ext)
 {
     $fsFile = new FSFile($path);
     $info = $this->newPlaceholderProps();
     $info['fileExists'] = $fsFile->exists();
     if ($info['fileExists']) {
         $info['size'] = $fsFile->getSize();
         // bytes
         $info['sha1'] = $fsFile->getSha1Base36();
         # MIME type according to file contents
         $info['file-mime'] = $this->magic->guessMimeType($path, false);
         # Logical MIME type
         $ext = $ext === true ? FileBackend::extensionFromPath($path) : $ext;
         $info['mime'] = $this->magic->improveTypeFromExtension($info['file-mime'], $ext);
         list($info['major_mime'], $info['minor_mime']) = File::splitMime($info['mime']);
         $info['media_type'] = $this->magic->getMediaType($path, $info['mime']);
         # Height, width and metadata
         $handler = MediaHandler::getHandler($info['mime']);
         if ($handler) {
             $info['metadata'] = $handler->getMetadata($fsFile, $path);
             /** @noinspection PhpMethodParametersCountMismatchInspection */
             $gis = $handler->getImageSize($fsFile, $path, $info['metadata']);
             if (is_array($gis)) {
                 $info = $this->extractImageSizeInfo($gis) + $info;
             }
         }
     }
     return $info;
 }
開發者ID:paladox,項目名稱:mediawiki,代碼行數:53,代碼來源:MWFileProps.php

示例2: testImproveTypeFromExtension

 /**
  * @dataProvider providerImproveTypeFromExtension
  * @param string $ext File extension (no leading dot)
  * @param string $oldMime Initially detected MIME
  * @param string $expectedMime MIME type after taking extension into account
  */
 function testImproveTypeFromExtension($ext, $oldMime, $expectedMime)
 {
     $actualMime = $this->mimeMagic->improveTypeFromExtension($oldMime, $ext);
     $this->assertEquals($expectedMime, $actualMime);
 }
開發者ID:eliagbayani,項目名稱:LiteratureEditor,代碼行數:11,代碼來源:MimeMagicTest.php


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