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


PHP JImage::getPath方法代碼示例

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


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

示例1: save


//.........這裏部分代碼省略.........
         }
     }
     $path = '';
     $path_hover = '';
     jimport('joomla.filesystem.file');
     $imageType = null;
     $imageMimeType = null;
     $imageSize = null;
     $image_hoverType = null;
     $image_hoverMimeType = null;
     $image_hoverSize = null;
     // Create original image with new name (upload from client)
     if (count($images) && !empty($images['tmp_name'])) {
         // Get image file type
         $imageType = JFile::getExt($images['name']);
         $imageType = strtolower($imageType);
         // Get image's mime type
         $imageMimeType = $images['type'];
         // Get image's size
         $imageSize = $images['size'];
         $path = COM_TZ_PORTFOLIO_PLUS_MEDIA_ARTICLE_ROOT . DIRECTORY_SEPARATOR;
         $path .= $data->alias . '-' . $data->id . '_o';
         $path .= '.' . JFile::getExt($images['name']);
         if ($input->getCmd('task') == 'save2copy' && $input->getInt('id')) {
             $image_data['url_server'] = null;
         }
     } elseif (isset($image_data['url_server']) && !empty($image_data['url_server'])) {
         // Create original image with new name (upload from server)
         // Get image file type
         $imageType = JFile::getExt($image_data['url_server']);
         $imageType = strtolower($imageType);
         // Get image's mime type
         $imageObj->loadFile(JPATH_ROOT . DIRECTORY_SEPARATOR . $image_data['url_server']);
         $imageMimeType = $imageObj->getImageFileProperties($imageObj->getPath());
         $imageMimeType = $imageMimeType->mime;
         // Get image's size
         $imageSize = $imageMimeType->filesize;
         $path = COM_TZ_PORTFOLIO_PLUS_MEDIA_ARTICLE_ROOT . DIRECTORY_SEPARATOR;
         $path .= $data->alias . '-' . $data->id . '_o';
         $path .= '.' . JFile::getExt($image_data['url_server']);
     }
     // Create original image hover with new name (upload from client)
     if (count($images_hover) && !empty($images_hover['tmp_name'])) {
         // Get image hover file type
         $image_hoverType = JFile::getExt($images_hover['name']);
         $image_hoverType = strtolower($image_hoverType);
         // Get image hover's mime type
         $image_hoverMimeType = $images_hover['type'];
         // Get image's size
         $image_hoverSize = $images_hover['size'];
         $path_hover = COM_TZ_PORTFOLIO_PLUS_MEDIA_ARTICLE_ROOT . DIRECTORY_SEPARATOR;
         $path_hover .= $data->alias . '-' . $data->id . '-h_o';
         $path_hover .= '.' . JFile::getExt($images_hover['name']);
         if ($input->getCmd('task') == 'save2copy' && $input->getInt('id')) {
             $image_data['url_hover_server'] = null;
         }
     } elseif (isset($image_data['url_hover_server']) && !empty($image_data['url_hover_server'])) {
         // Create original image with new name (upload from server)
         // Get image hover file type
         $image_hoverType = JFile::getExt($image_data['url_hover_server']);
         $image_hoverType = strtolower($image_hoverType);
         // Get image hover's mime type
         $imageObj->loadFile(JPATH_ROOT . DIRECTORY_SEPARATOR . $image_data['url_hover_server']);
         $image_hoverMimeType = $imageObj->getImageFileProperties($imageObj->getPath());
         $image_hoverMimeType = $image_hoverMimeType->mime;
         // Get image hover's size
開發者ID:templaza,項目名稱:tz_portfolio_plus,代碼行數:67,代碼來源:image.php

示例2: getThumbnail

 public static function getThumbnail($image)
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $params = JComponentHelper::getComponent('com_digicom')->params;
     if (empty($image)) {
         return '';
     }
     if (!JFile::exists($image)) {
         return $image;
     }
     if ($params->get('image_thumb_enable')) {
         $image_thumb_width = $params->get('image_thumb_width');
         $image_thumb_height = $params->get('image_thumb_height');
         $image_thumb_method = $params->get('image_thumb_method', 6);
         $imageunique = md5($image . $image_thumb_width . $image_thumb_height);
         $path = JPATH_ROOT . '/images/digicom/products';
         JFolder::create($path);
         // Generate thumb name
         $jimage = new JImage($image);
         $filename = pathinfo($jimage->getPath(), PATHINFO_FILENAME);
         $fileExtension = pathinfo($jimage->getPath(), PATHINFO_EXTENSION);
         $thumbFileName = $filename . '_' . $image_thumb_width . 'x' . $image_thumb_height . '.' . $fileExtension;
         $thumbpath = JPATH_ROOT . '/images/digicom/products/' . $thumbFileName;
         $thumburl = JURI::root() . 'images/digicom/products/' . $thumbFileName;
         if (JFile::exists($thumbpath)) {
             return $thumburl;
         }
         $image = $jimage->createThumbs(array($image_thumb_width . 'x' . $image_thumb_height), $image_thumb_method, $path);
         $thumburl = str_replace(JPATH_SITE . '/', '', $image[0]->getPath());
         return $thumburl;
     } else {
         return $image;
     }
 }
開發者ID:Shtier,項目名稱:digicom,代碼行數:35,代碼來源:digicom.php

示例3: createImage

 /**
  * Create a cropped and resized image from the uploaded original
  *
  * @return bool
  *
  * @since   1.0.0.3
  */
 protected function createImage($src, $dest, $width, $height)
 {
     $original = new JImage($src);
     $org_width = $original->getWidth();
     $org_height = $original->getHeight();
     if ($org_width / $width < $org_height / $height) {
         $original->resize($width, 0, false);
     } else {
         $original->resize(0, $height, false);
     }
     $thumb = $original->crop($width, $height, null, null, true);
     $filename = pathinfo($original->getPath(), PATHINFO_FILENAME);
     $extension = pathinfo($original->getPath(), PATHINFO_EXTENSION);
     if (!$thumb->toFile(JPATH_ROOT . $dest . $filename . "." . $extension)) {
         return false;
     }
     $original->destroy();
     $thumb->destroy();
     return true;
 }
開發者ID:SchoolDangersOrg,項目名稱:com_mapbox,代碼行數:27,代碼來源:images.php


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