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


PHP PerchUtil::get_mime_type方法代码示例

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


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

示例1: get_meta

 /**
  * Get the file size, and other meta like dimensions for images
  * @return [type] [description]
  */
 public function get_meta()
 {
     $file_path = $this->file_path();
     $out = array();
     $out['resourceFileSize'] = 0;
     if (file_exists($file_path)) {
         $out['resourceFileSize'] = filesize($file_path);
     }
     if ($this->is_image() && $out['resourceFileSize'] > 0) {
         $Image = new PerchImage();
         $out['resourceCrop'] = 0;
         if ($this->resourceType() == 'svg') {
             $info = $Image->get_svg_size($file_path);
         } else {
             PerchUtil::debug('Get image size: ' . $file_path);
             $info = getimagesize($file_path);
         }
         if ($info) {
             $out['resourceWidth'] = $info[0];
             $out['resourceHeight'] = $info[1];
         }
         if ($info && isset($info['mime'])) {
             $out['resourceMimeType'] = $info['mime'];
         } else {
             $out['resourceMimeType'] = PerchUtil::get_mime_type($this->file_path());
         }
         // get target info from file name
         $targets = $Image->parse_file_name($this->resourceFile());
         if ($targets) {
             if (isset($targets['w'])) {
                 $out['resourceTargetWidth'] = $targets['w'];
             }
             if (isset($targets['h'])) {
                 $out['resourceTargetHeight'] = $targets['h'];
             }
             if (isset($targets['c'])) {
                 $out['resourceCrop'] = $targets['c'];
             }
             if (isset($targets['d'])) {
                 $out['resourceDensity'] = $targets['d'];
                 $out['resourceWidth'] = $out['resourceWidth'] / $targets['d'];
                 $out['resourceHeight'] = $out['resourceHeight'] / $targets['d'];
                 PerchUtil::debug('Yes');
             }
         }
         if (isset($out['resourceWidth']) && isset($out['resourceTargetWidth']) && isset($out['resourceHeight']) && isset($out['resourceTargetHeight'])) {
             if ($out['resourceWidth'] == $out['resourceTargetWidth'] && $out['resourceHeight'] == $out['resourceTargetHeight']) {
                 $out['resourceCrop'] = '1';
             }
         }
     } else {
         $out['resourceMimeType'] = PerchUtil::get_mime_type($this->file_path());
     }
     if (isset($out['resourceWidth'])) {
         $out['resourceWidth'] = (int) $out['resourceWidth'];
     }
     if (isset($out['resourceHeight'])) {
         $out['resourceHeight'] = (int) $out['resourceHeight'];
     }
     return $out;
 }
开发者ID:jaredmedley,项目名称:Perch-Core-Files,代码行数:65,代码来源:PerchAssets_Asset.class.php

示例2: get_raw

 public function get_raw($post = false, $Item = false)
 {
     $store = array();
     $Perch = Perch::fetch();
     $Bucket = PerchResourceBuckets::get($this->Tag->bucket());
     $image_folder_writable = $Bucket->ready_to_write();
     $item_id = $this->Tag->input_id();
     $asset_reference_used = false;
     $target = false;
     $filesize = false;
     if (!class_exists('PerchAssets_Assets', false)) {
         include_once PERCH_CORE . '/apps/assets/PerchAssets_Assets.class.php';
         include_once PERCH_CORE . '/apps/assets/PerchAssets_Asset.class.php';
     }
     $Assets = new PerchAssets_Assets();
     $AssetMeta = false;
     // Asset ID?
     if (isset($post[$this->Tag->id() . '_assetID']) && $post[$this->Tag->id() . '_assetID'] != '') {
         $new_assetID = $post[$this->Tag->id() . '_assetID'];
         $Asset = $Assets->find($new_assetID);
         if (is_object($Asset)) {
             $target = $Asset->file_path();
             $filename = $Asset->resourceFile();
             $store['assetID'] = $Asset->id();
             $store['title'] = $Asset->resourceTitle();
             $store['_default'] = $Asset->web_path();
             $store['bucket'] = $Asset->resourceBucket();
             if ($store['bucket'] != $Bucket->get_name()) {
                 $Bucket = PerchResourceBuckets::get($store['bucket']);
             }
             $asset_reference_used = true;
         }
     }
     if ($image_folder_writable && isset($_FILES[$item_id]) && (int) $_FILES[$item_id]['size'] > 0) {
         if (!isset(self::$file_paths[$this->Tag->id()])) {
             // We do this before writing to the bucket, as it performs better for remote buckets.
             $AssetMeta = $Assets->get_meta_data($_FILES[$item_id]['tmp_name'], $_FILES[$item_id]['name']);
             $result = $Bucket->write_file($_FILES[$item_id]['tmp_name'], $_FILES[$item_id]['name']);
             $target = $result['path'];
             $filename = $result['name'];
             $filesize = (int) $_FILES[$item_id]['size'];
             $store['_default'] = rtrim($Bucket->get_web_path(), '/') . '/' . $filename;
             // fire events
             if ($this->Tag->type() == 'image') {
                 $PerchImage = new PerchImage();
                 $profile = $PerchImage->get_resize_profile($target);
                 $profile['original'] = true;
                 $Perch->event('assets.upload_image', new PerchAssetFile($profile));
             }
         }
     }
     if ($target && $filename && is_file($target)) {
         self::$file_paths[$this->Tag->id()] = $target;
         $store['path'] = $filename;
         $store['size'] = $filesize ?: filesize($target);
         $store['bucket'] = $Bucket->get_name();
         // Is this an SVG?
         $svg = false;
         $size = getimagesize($target);
         if (PerchUtil::count($size)) {
             $store['w'] = $size[0];
             $store['h'] = $size[1];
             if (isset($size['mime'])) {
                 $store['mime'] = $size['mime'];
             }
         } else {
             $PerchImage = new PerchImage();
             if ($PerchImage->is_webp($target)) {
                 $store['mime'] = 'image/webp';
             } elseif ($PerchImage->is_svg($target)) {
                 $svg = true;
                 $size = $PerchImage->get_svg_size($target);
                 if (PerchUtil::count($size)) {
                     $store['w'] = $size['w'];
                     $store['h'] = $size['h'];
                     if (isset($size['mime'])) {
                         $store['mime'] = $size['mime'];
                     }
                 }
             } else {
                 // It's not an image (according to getimagesize) and not an SVG.
                 if ($this->Tag->detect_type()) {
                     // if we have permission to guess, our guess is that it's a file.
                     PerchUtil::debug('Guessing file', 'error');
                     $this->Tag->set('type', 'file');
                 }
                 $store['mime'] = PerchUtil::get_mime_type($target);
             }
         }
         // thumbnail
         if ($this->Tag->type() == 'image') {
             $PerchImage = new PerchImage();
             $PerchImage->set_density(2);
             $result = false;
             if ($asset_reference_used) {
                 $result = $Assets->get_resize_profile($store['assetID'], 150, 150, false, 'thumb', $PerchImage->get_density());
             }
             if (!$result) {
                 $result = $PerchImage->resize_image($target, 150, 150, false, 'thumb');
             }
//.........这里部分代码省略.........
开发者ID:jaredmedley,项目名称:Perch-Core-Files,代码行数:101,代码来源:PerchFieldTypes.class.php

示例3: get_mime_type

 public function get_mime_type()
 {
     return PerchUtil::get_mime_type($this->details['file_path']);
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:4,代码来源:PerchAssetFile.class.php


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