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


PHP Thumbnail::createReflection方法代碼示例

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


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

示例1: getThumb

 function getThumb($text, $size = 70, $reflections = false)
 {
     preg_match("/\\<img.+?src=\"(.+?)\".+?\\/>/", $text, $matches);
     $paths = array();
     if (isset($matches[1])) {
         $image_path = $matches[1];
         //joomla 1.5 only
         $full_url = JURI::base();
         //remove any protocol/site info from the image path
         $parsed_url = parse_url($full_url);
         $paths[] = $full_url;
         if (isset($parsed_url['path']) && $parsed_url['path'] != "/") {
             $paths[] = $parsed_url['path'];
         }
         foreach ($paths as $path) {
             if (strpos($image_path, $path) !== false) {
                 $image_path = substr($image_path, strpos($image_path, $path) + strlen($path));
             }
         }
         // remove any / that begins the path
         if (substr($image_path, 0, 1) == '/') {
             $image_path = substr($image_path, 1);
         }
         //if after removing the uri, still has protocol then the image
         //is remote and we don't support thumbs for external images
         if (strpos($image_path, 'http://') !== false || strpos($image_path, 'https://') !== false) {
             return false;
         }
         // create a thumb filename
         $file_div = strrpos($image_path, '.');
         $thumb_ext = substr($image_path, $file_div);
         $thumb_prev = substr($image_path, 0, $file_div);
         $thumb_path = $thumb_prev . "_thumb" . $thumb_ext;
         // check to see if this file exists, if so we don't need to create it
         if (function_exists("gd_info") && !file_exists($thumb_path)) {
             // file doens't exist, so create it and save it
             include_once 'thumbnail.inc.php';
             $thumb = new Thumbnail($image_path);
             if ($thumb->error) {
                 if (MICRONEWS) {
                     echo "ROKMININEWS ERROR: " . $thumb->errmsg . ": " . $image_path;
                 }
                 return false;
             }
             $thumb->resize($size);
             if ($reflections) {
                 $thumb->createReflection(30, 30, 60, false);
             }
             if (!is_writable(dirname($thumb_path))) {
                 $thumb->destruct();
                 return false;
             }
             $thumb->save($thumb_path);
             $thumb->destruct();
         }
         return $thumb_path;
     } else {
         return false;
     }
 }
開發者ID:jnvilo,項目名稱:tomasinasanctuary.org,代碼行數:60,代碼來源:helper.php


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