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


PHP BigTree::getThumbnailSizes方法代码示例

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


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

示例1: array

 // We're going to create a list view and detail view thumbnail plus whatever we're requesting to have through Settings
 $thumbnails_to_create = array("bigtree_internal_list" => array("width" => 100, "height" => 100, "prefix" => "bigtree_list_thumb_"), "bigtree_internal_detail" => array("width" => 190, "height" => 145, "prefix" => "bigtree_detail_thumb_"));
 $more_thumb_types = $cms->getSetting("bigtree-file-manager-thumbnail-sizes");
 if (is_array($more_thumb_types)) {
     foreach ($more_thumb_types as $thumb) {
         $thumbnails_to_create[$thumb["title"]] = $thumb;
     }
 }
 // Do lots of image awesomesauce.
 $itype_exts = array(IMAGETYPE_PNG => ".png", IMAGETYPE_JPEG => ".jpg", IMAGETYPE_GIF => ".gif");
 $first_copy = $temp_name;
 list($iwidth, $iheight, $itype, $iattr) = getimagesize($first_copy);
 foreach ($thumbnails_to_create as $thumb) {
     // We don't want to add multiple errors and we also don't want to waste effort getting thumbnail sizes if we already failed.
     if (!$error) {
         $sizes = BigTree::getThumbnailSizes($first_copy, $thumb["width"], $thumb["height"]);
         if (!BigTree::imageManipulationMemoryAvailable($first_copy, $sizes[3], $sizes[4], $iwidth, $iheight)) {
             $error = "Image uploaded is too large for the server to manipulate. Please upload a smaller version of this image.";
             unlink($first_copy);
         }
     }
 }
 if (!$error) {
     // Now let's make the thumbnails we need for the image manager
     $thumbs = array();
     $pinfo = BigTree::pathInfo($file_name);
     // Create a bunch of thumbnails
     foreach ($thumbnails_to_create as $key => $thumb) {
         if ($iwidth > $thumb["width"] || $iheight > $thumb["height"]) {
             $temp_thumb = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
             BigTree::createThumbnail($first_copy, $temp_thumb, $thumb["width"], $thumb["height"]);
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:31,代码来源:upload.php

示例2: processImageUpload

 static function processImageUpload($field)
 {
     global $bigtree;
     $failed = false;
     $name = $field["file_input"]["name"];
     $temp_name = $field["file_input"]["tmp_name"];
     $error = $field["file_input"]["error"];
     // If a file upload error occurred, return the old image and set errors
     if ($error == 1 || $error == 2) {
         $bigtree["errors"][] = array("field" => $field["title"], "error" => "The file you uploaded ({$name}) was too large &mdash; <strong>Max file size: " . ini_get("upload_max_filesize") . "</strong>");
         return false;
     } elseif ($error == 3) {
         $bigtree["errors"][] = array("field" => $field["title"], "error" => "The file upload failed ({$name}).");
         return false;
     }
     // We're going to tell BigTreeStorage to handle forcing images into JPEGs instead of writing the code 20x
     $storage = new BigTreeStorage();
     $storage->AutoJPEG = $bigtree["config"]["image_force_jpeg"];
     // Let's check the minimum requirements for the image first before we store it anywhere.
     $image_info = @getimagesize($temp_name);
     $iwidth = $image_info[0];
     $iheight = $image_info[1];
     $itype = $image_info[2];
     $channels = $image_info["channels"];
     // See if we're using image presets
     if ($field["options"]["preset"]) {
         $media_settings = BigTreeCMS::getSetting("bigtree-internal-media-settings");
         $preset = $media_settings["presets"][$field["options"]["preset"]];
         // If the preset still exists, copy its properties over to our options
         if ($preset) {
             foreach ($preset as $key => $val) {
                 $field["options"][$key] = $val;
             }
         }
     }
     // If the minimum height or width is not meant, do NOT let the image through.  Erase the change or update from the database.
     if (isset($field["options"]["min_height"]) && $iheight < $field["options"]["min_height"] || isset($field["options"]["min_width"]) && $iwidth < $field["options"]["min_width"]) {
         $error = "Image uploaded (" . htmlspecialchars($name) . ") did not meet the minimum size of ";
         if ($field["options"]["min_height"] && $field["options"]["min_width"]) {
             $error .= $field["options"]["min_width"] . "x" . $field["options"]["min_height"] . " pixels.";
         } elseif ($field["options"]["min_height"]) {
             $error .= $field["options"]["min_height"] . " pixels tall.";
         } elseif ($field["options"]["min_width"]) {
             $error .= $field["options"]["min_width"] . " pixels wide.";
         }
         $bigtree["errors"][] = array("field" => $field["title"], "error" => $error);
         $failed = true;
     }
     // If it's not a valid image, throw it out!
     if ($itype != IMAGETYPE_GIF && $itype != IMAGETYPE_JPEG && $itype != IMAGETYPE_PNG) {
         $bigtree["errors"][] = array("field" => $field["title"], "error" => "An invalid file was uploaded. Valid file types: JPG, GIF, PNG.");
         $failed = true;
     }
     // See if it's CMYK
     if ($channels == 4) {
         $bigtree["errors"][] = array("field" => $field["title"], "error" => "A CMYK encoded file was uploaded. Please upload an RBG image.");
         $failed = true;
     }
     // See if we have enough memory for all our crops and thumbnails
     if (!$failed && (is_array($field["options"]["crops"]) && count($field["options"]["crops"]) || is_array($field["options"]["thumbs"]) && count($field["options"]["thumbs"]))) {
         if (is_array($field["options"]["crops"])) {
             foreach ($field["options"]["crops"] as $crop) {
                 if (!$failed && is_array($crop) && array_filter($crop)) {
                     if ($field["options"]["retina"]) {
                         $crop["width"] *= 2;
                         $crop["height"] *= 2;
                     }
                     // We don't want to add multiple errors so we check if we've already failed
                     if (!BigTree::imageManipulationMemoryAvailable($temp_name, $crop["width"], $crop["height"], $iwidth, $iheight)) {
                         $bigtree["errors"][] = array("field" => $field["title"], "error" => "Image uploaded is too large for the server to manipulate. Please upload a smaller version of this image.");
                         $failed = true;
                     }
                 }
             }
         }
         if (is_array($field["options"]["thumbs"])) {
             foreach ($field["options"]["thumbs"] as $thumb) {
                 // We don't want to add multiple errors and we also don't want to waste effort getting thumbnail sizes if we already failed.
                 if (!$failed && is_array($thumb) && array_filter($thumb)) {
                     if ($field["options"]["retina"]) {
                         $thumb["width"] *= 2;
                         $thumb["height"] *= 2;
                     }
                     $sizes = BigTree::getThumbnailSizes($temp_name, $thumb["width"], $thumb["height"]);
                     if (!BigTree::imageManipulationMemoryAvailable($temp_name, $sizes[3], $sizes[4], $iwidth, $iheight)) {
                         $bigtree["errors"][] = array("field" => $field["title"], "error" => "Image uploaded is too large for the server to manipulate. Please upload a smaller version of this image.");
                         $failed = true;
                     }
                 }
             }
         }
         if (is_array($field["options"]["center_crops"])) {
             foreach ($field["options"]["center_crops"] as $crop) {
                 // We don't want to add multiple errors and we also don't want to waste effort getting thumbnail sizes if we already failed.
                 if (!$failed && is_array($crop) && array_filter($crop)) {
                     list($w, $h) = getimagesize($temp_name);
                     if (!BigTree::imageManipulationMemoryAvailable($temp_name, $w, $h, $crop["width"], $crop["height"])) {
                         $bigtree["errors"][] = array("field" => $field["title"], "error" => "Image uploaded is too large for the server to manipulate. Please upload a smaller version of this image.");
                         $failed = true;
                     }
//.........这里部分代码省略.........
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:101,代码来源:admin.php


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