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


PHP MediaHelper::imageResize方法代码示例

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


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

示例1: getProperties

 /**
  * Return the file properties of a specific file
  *
  * @param string $filePath
  *
  * @return array
  */
 public function getProperties($filePath)
 {
     $properties = array();
     $info = @getimagesize($filePath);
     $properties['width'] = @$info[0];
     $properties['height'] = @$info[1];
     $properties['type'] = @$info[2];
     $properties['mime'] = @$info['mime'];
     if ($info[0] > 60 || $info[1] > 60) {
         $dimensions = MediaHelper::imageResize($info[0], $info[1], 60);
         $properties['width_60'] = $dimensions[0];
         $properties['height_60'] = $dimensions[1];
     } else {
         $properties['width_60'] = $properties['width'];
         $properties['height_60'] = $properties['height'];
     }
     if ($info[0] > 16 || $info[1] > 16) {
         $dimensions = MediaHelper::imageResize($info[0], $info[1], 16);
         $properties['width_16'] = $dimensions[0];
         $properties['height_16'] = $dimensions[1];
     } else {
         $properties['width_16'] = $properties['width'];
         $properties['height_16'] = $properties['height'];
     }
     return $properties;
 }
开发者ID:dgt41,项目名称:media-manager-improvement,代码行数:33,代码来源:image.php

示例2: getList

 /**
  * Method to return the current filelist
  *
  * @access public
  * @param null
  * @return array
  */
 public function getList()
 {
     // Only process the list once per request
     static $list;
     if (is_array($list)) {
         return $list;
     }
     // Initialize variables
     $folder = $this->getState('folder');
     $folderPath = JPATH_SITE . '/' . $folder;
     $type = $this->getState('type');
     // Initialize the lists
     $files = array();
     $subfolders = array();
     $docs = array();
     // Get the list of files and folders from the given folder
     if (is_readable($folderPath)) {
         $fileList = JFolder::files($folderPath);
         $subfolderList = JFolder::folders($folderPath);
     } else {
         $fileList = false;
         $subfolderList = false;
     }
     // Iterate over the files if they exist
     if ($fileList !== false) {
         foreach ($fileList as $file) {
             // Skip this file if it is not readable
             if (is_file($folderPath . '/' . $file) == false) {
                 continue;
             }
             // Skip files starting with a dot
             if (substr($file, 0, 1) == '.') {
                 continue;
             }
             // Skip specific files
             if (strtolower($file) == 'index.html' || preg_match('/\\.(php)$/', $file)) {
                 continue;
             }
             $tmp = new JObject();
             $tmp->name = $file;
             $tmp->path = $folderPath . '/' . $file;
             $tmp->path_relative = $folder . $file;
             $tmp->path_uri = $tmp->path_relative;
             $tmp->size = filesize($tmp->path);
             $ext = strtolower(JFile::getExt($file));
             switch ($ext) {
                 // Image
                 case 'jpg':
                 case 'png':
                 case 'gif':
                 case 'xcf':
                 case 'odg':
                 case 'bmp':
                 case 'jpeg':
                     $info = @getimagesize($tmp->path);
                     $size = @filesize($tmp->path);
                     $tmp->width = @$info[0];
                     $tmp->height = @$info[1];
                     $tmp->src_width = $tmp->width;
                     $tmp->src_height = $tmp->height;
                     $tmp->type = @$info[2];
                     $tmp->mime = @$info['mime'];
                     $maxsize = 60;
                     if ($info[0] > $maxsize || $info[1] > $maxsize) {
                         $dimensions = MediaHelper::imageResize($info[0], $info[1], $maxsize);
                         $tmp->width = $dimensions[0];
                         $tmp->height = $dimensions[1];
                     }
                     $maxbits = 524288;
                     if ($size > $maxbits) {
                         $tmp->src = JURI::root() . SimplelistsHelper::createThumbnail($tmp->path, $ext, $tmp->src_width, $tmp->src_height, $tmp->width, $tmp->height);
                     } else {
                         $tmp->src = JURI::root() . $tmp->path_relative;
                     }
                     $files[] = $tmp;
                     break;
                     // Non-image document
                 // Non-image document
                 default:
                     if ($type != 'link_file') {
                         break;
                     }
                     // First read the Media Manager parameters and check if this extension is allowed
                     $media_params = JComponentHelper::getParams('com_media');
                     $allowable = explode(',', $media_params->get('upload_extensions'));
                     if (in_array($ext, $allowable) == false) {
                         break;
                     }
                     if (file_exists(JPATH_SITE . '/media/media/images/mime-icon-32/' . $ext . '.png')) {
                         $tmp->path_relative = '/media/media/images/mime-icon-32/' . $ext . '.png';
                     } elseif (file_exists(JPATH_SITE . '/media/media/images/con_info.png')) {
                         $tmp->path_relative = '/media/media/images/con_info.png';
                     } elseif (file_exists(JPATH_ADMINISTRATOR . '/components/com_media/images/mime-icon-32/' . $ext . '.png')) {
//.........这里部分代码省略.........
开发者ID:renekreijveld,项目名称:SimpleLists,代码行数:101,代码来源:files.php

示例3: getList

 /**
  * Build imagelist
  *
  * @param string $listFolder The image directory to display
  * @since 1.5
  */
 public function getList()
 {
     static $list;
     // Only process the list once per request
     if (is_array($list)) {
         return $list;
     }
     // Get current path from request
     $current = $this->getState('folder');
     // If undefined, set to empty
     if ($current == 'undefined') {
         $current = '';
     }
     if (strlen($current) > 0) {
         $basePath = COM_MEDIA_BASE . '/' . $current;
     } else {
         $basePath = COM_MEDIA_BASE;
     }
     $mediaBase = str_replace(DIRECTORY_SEPARATOR, '/', COM_MEDIA_BASE . '/');
     $images = array();
     $folders = array();
     $docs = array();
     $fileList = false;
     $folderList = false;
     if (file_exists($basePath)) {
         // Get the list of files and folders from the given folder
         $fileList = JFolder::files($basePath);
         $folderList = JFolder::folders($basePath);
     }
     // Iterate over the files if they exist
     if ($fileList !== false) {
         foreach ($fileList as $file) {
             if (is_file($basePath . '/' . $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
                 $tmp = new JObject();
                 $tmp->name = $file;
                 $tmp->title = $file;
                 $tmp->path = str_replace(DIRECTORY_SEPARATOR, '/', JPath::clean($basePath . '/' . $file));
                 $tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
                 $tmp->size = filesize($tmp->path);
                 $ext = strtolower(JFile::getExt($file));
                 switch ($ext) {
                     // Image
                     case 'jpg':
                     case 'png':
                     case 'gif':
                     case 'xcf':
                     case 'odg':
                     case 'bmp':
                     case 'jpeg':
                     case 'ico':
                         $info = @getimagesize($tmp->path);
                         $tmp->width = @$info[0];
                         $tmp->height = @$info[1];
                         $tmp->type = @$info[2];
                         $tmp->mime = @$info['mime'];
                         if ($info[0] > 60 || $info[1] > 60) {
                             $dimensions = MediaHelper::imageResize($info[0], $info[1], 60);
                             $tmp->width_60 = $dimensions[0];
                             $tmp->height_60 = $dimensions[1];
                         } else {
                             $tmp->width_60 = $tmp->width;
                             $tmp->height_60 = $tmp->height;
                         }
                         if ($info[0] > 16 || $info[1] > 16) {
                             $dimensions = MediaHelper::imageResize($info[0], $info[1], 16);
                             $tmp->width_16 = $dimensions[0];
                             $tmp->height_16 = $dimensions[1];
                         } else {
                             $tmp->width_16 = $tmp->width;
                             $tmp->height_16 = $tmp->height;
                         }
                         $images[] = $tmp;
                         break;
                         // Non-image document
                     // Non-image document
                     default:
                         $tmp->icon_32 = "media/mime-icon-32/" . $ext . ".png";
                         $tmp->icon_16 = "media/mime-icon-16/" . $ext . ".png";
                         $docs[] = $tmp;
                         break;
                 }
             }
         }
     }
     // Iterate over the folders if they exist
     if ($folderList !== false) {
         foreach ($folderList as $folder) {
             $tmp = new JObject();
             $tmp->name = basename($folder);
             $tmp->path = str_replace(DIRECTORY_SEPARATOR, '/', JPath::clean($basePath . '/' . $folder));
             $tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
             $count = MediaHelper::countFiles($tmp->path);
             $tmp->files = $count[0];
             $tmp->folders = $count[1];
//.........这里部分代码省略.........
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:101,代码来源:list.php

示例4: getList

 function getList()
 {
     // Get current path from request
     $current = $this->getStateFolder();
     // If undefined, set to empty
     if ($current == 'undefined') {
         $current = '';
     }
     // Initialize variables
     if (strlen($current) > 0) {
         $basePath = $this->comMediaBase . DS . $current;
         //$basePath = $current;
     } else {
         $basePath = $this->comMediaBase;
     }
     $mediaBase = str_replace(DS, '/', $this->comMediaBase . '/');
     $images = array();
     $folders = array();
     $docs = array();
     // Get the list of files and folders from the given folder
     $fileList = JFolder::files($basePath);
     $folderList = JFolder::folders($basePath);
     jimport('joomla.filesystem.file');
     // Iterate over the files if they exist
     if ($fileList !== false) {
         foreach ($fileList as $file) {
             if (is_file($basePath . DS . $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
                 $tmp = new JObject();
                 $tmp->name = $file;
                 $tmp->path = str_replace(DS, '/', JPath::clean($basePath . DS . $file));
                 $tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
                 $tmp->size = filesize($tmp->path);
                 $ext = strtolower(JFile::getExt($file));
                 switch ($ext) {
                     // Image
                     case 'jpg':
                     case 'png':
                     case 'gif':
                     case 'xcf':
                     case 'odg':
                     case 'bmp':
                     case 'jpeg':
                         $info = @getimagesize($tmp->path);
                         $tmp->width = @$info[0];
                         $tmp->height = @$info[1];
                         $tmp->type = @$info[2];
                         $tmp->mime = @$info['mime'];
                         $filesize = MediaHelper::parseSize($tmp->size);
                         if ($info[0] > 60 || $info[1] > 60) {
                             $dimensions = MediaHelper::imageResize($info[0], $info[1], 60);
                             $tmp->width_60 = $dimensions[0];
                             $tmp->height_60 = $dimensions[1];
                         } else {
                             $tmp->width_60 = $tmp->width;
                             $tmp->height_60 = $tmp->height;
                         }
                         if ($info[0] > 16 || $info[1] > 16) {
                             $dimensions = MediaHelper::imageResize($info[0], $info[1], 16);
                             $tmp->width_16 = $dimensions[0];
                             $tmp->height_16 = $dimensions[1];
                         } else {
                             $tmp->width_16 = $tmp->width;
                             $tmp->height_16 = $tmp->height;
                         }
                         $images[] = $tmp;
                         break;
                         // Non-image document
                     // Non-image document
                     default:
                         $iconfile_32 = JPATH_ADMINISTRATOR . DS . "components" . DS . "com_imageshow" . DS . "assets" . DS . "images" . DS . "mime-icon-32" . DS . $ext . ".png";
                         if (file_exists($iconfile_32)) {
                             $tmp->icon_32 = "components/com_imageshow/assets/images/mime-icon-32/" . $ext . ".png";
                         } else {
                             $tmp->icon_32 = "components/com_imageshow/assets/images/con_info.png";
                         }
                         $iconfile_16 = JPATH_ADMINISTRATOR . DS . "components" . DS . "com_imageshow" . DS . "assets" . DS . "images" . DS . "mime-icon-16" . DS . $ext . ".png";
                         if (file_exists($iconfile_16)) {
                             $tmp->icon_16 = "components/com_imageshow/assets/images/mime-icon-16/" . $ext . ".png";
                         } else {
                             $tmp->icon_16 = "components/com_imageshow/assets/images/con_info.png";
                         }
                         $docs[] = $tmp;
                         break;
                 }
             }
         }
     }
     // Iterate over the folders if they exist
     if ($folderList !== false) {
         foreach ($folderList as $folder) {
             $tmp = new JObject();
             $tmp->name = basename($folder);
             $tmp->path = str_replace(DS, '/', JPath::clean($basePath . DS . $folder));
             $tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
             $count = MediaHelper::countFiles($tmp->path);
             $tmp->files = $count[0];
             $tmp->folders = $count[1];
             $folders[] = $tmp;
         }
     }
//.........这里部分代码省略.........
开发者ID:sangkasi,项目名称:joomla,代码行数:101,代码来源:jsn_is_mediamanager.php


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