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


PHP Cloudinary::build_array方法代码示例

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


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

示例1: build_eager

 public static function build_eager($transformations)
 {
     $eager = array();
     foreach (\Cloudinary::build_array($transformations) as $trans) {
         $transformation = $trans;
         $format = \Cloudinary::option_consume($transformation, "format");
         $single_eager = implode("/", array_filter(array(\Cloudinary::generate_transformation_string($transformation), $format)));
         array_push($eager, $single_eager);
     }
     return implode("|", $eager);
 }
开发者ID:ShanksGtr,项目名称:AdminerTest,代码行数:11,代码来源:Cloudinary.php

示例2: build_responsive_breakpoints

 protected static function build_responsive_breakpoints($breakpoints)
 {
     if (!$breakpoints) {
         return NULL;
     }
     $breakpoints_params = array();
     foreach (\Cloudinary::build_array($breakpoints) as $breakpoint_settings) {
         if ($breakpoint_settings) {
             $transformation = \Cloudinary::option_consume($breakpoint_settings, "transformation");
             if ($transformation) {
                 $breakpoint_settings["transformation"] = \Cloudinary::generate_transformation_string($transformation);
             }
             array_push($breakpoints_params, $breakpoint_settings);
         }
     }
     return json_encode($breakpoints_params);
 }
开发者ID:IVsevolod,项目名称:zouk,代码行数:17,代码来源:Uploader.php

示例3: generate_transformation_string

 public static function generate_transformation_string(&$options = array())
 {
     $generate_base_transformation = array("Cloudinary", "generate_base_transformation");
     if ($options == array_values($options)) {
         return implode("/", array_map($generate_base_transformation, $options));
     }
     $size = Cloudinary::option_consume($options, "size");
     if ($size) {
         list($options["width"], $options["height"]) = preg_split("/x/", $size);
     }
     $width = Cloudinary::option_get($options, "width");
     $height = Cloudinary::option_get($options, "height");
     $has_layer = Cloudinary::option_get($options, "underlay") || Cloudinary::option_get($options, "overlay");
     if ($width && (floatval($width) < 1 || $has_layer)) {
         unset($options["width"]);
     }
     if ($height && (floatval($height) < 1 || $has_layer)) {
         unset($options["height"]);
     }
     $angle = implode(Cloudinary::build_array(Cloudinary::option_consume($options, "angle")), ".");
     $crop = Cloudinary::option_consume($options, "crop");
     if (!$crop && !$has_layer) {
         $width = $height = NULL;
     }
     $background = Cloudinary::option_consume($options, "background");
     if ($background) {
         $background = preg_replace("/^#/", 'rgb:', $background);
     }
     $base_transformations = Cloudinary::build_array(Cloudinary::option_consume($options, "transformation"));
     if (count(array_filter($base_transformations, "is_array")) > 0) {
         $base_transformations = array_map($generate_base_transformation, $base_transformations);
         $named_transformation = "";
     } else {
         $named_transformation = implode(".", $base_transformations);
         $base_transformations = array();
     }
     $effect = Cloudinary::option_consume($options, "effect");
     if (is_array($effect)) {
         $effect = implode(":", $effect);
     }
     $border = Cloudinary::option_consume($options, "border");
     if (is_array($border)) {
         $border_width = Cloudinary::option_get($border, "width", "2");
         $border_color = preg_replace("/^#/", 'rgb:', Cloudinary::option_get($border, "color", "black"));
         $border = $border_width . "px_solid_" . $border_color;
     }
     $flags = implode(Cloudinary::build_array(Cloudinary::option_consume($options, "flags")), ".");
     $params = array("w" => $width, "h" => $height, "t" => $named_transformation, "c" => $crop, "b" => $background, "e" => $effect, "bo" => $border, "a" => $angle, "fl" => $flags);
     $simple_params = array("x" => "x", "y" => "y", "r" => "radius", "d" => "default_image", "g" => "gravity", "q" => "quality", "p" => "prefix", "l" => "overlay", "u" => "underlay", "f" => "fetch_format", "dn" => "density", "pg" => "page", "dl" => "delay", "cs" => "color_space");
     foreach ($simple_params as $param => $option) {
         $params[$param] = Cloudinary::option_consume($options, $option);
     }
     $params = array_filter($params);
     ksort($params);
     $join_pair_underscore = array("Cloudinary", "join_pair_underscore");
     $transformation = implode(",", array_map($join_pair_underscore, array_keys($params), array_values($params)));
     $raw_transformation = Cloudinary::option_consume($options, "raw_transformation");
     $transformation = implode(",", array_filter(array($transformation, $raw_transformation)));
     array_push($base_transformations, $transformation);
     return implode("/", array_filter($base_transformations));
 }
开发者ID:vanbungkring,项目名称:24custom,代码行数:61,代码来源:cloudinary_api.php

示例4: generate_transformation_string

 public static function generate_transformation_string(&$options = array())
 {
     $generate_base_transformation = "Cloudinary::generate_base_transformation";
     if (is_string($options)) {
         return $options;
     }
     if ($options == array_values($options)) {
         return implode("/", array_map($generate_base_transformation, $options));
     }
     $responsive_width = Cloudinary::option_consume($options, "responsive_width", Cloudinary::config_get("responsive_width"));
     $size = Cloudinary::option_consume($options, "size");
     if ($size) {
         list($options["width"], $options["height"]) = preg_split("/x/", $size);
     }
     $width = Cloudinary::option_get($options, "width");
     $height = Cloudinary::option_get($options, "height");
     $has_layer = Cloudinary::option_get($options, "underlay") || Cloudinary::option_get($options, "overlay");
     $angle = implode(Cloudinary::build_array(Cloudinary::option_consume($options, "angle")), ".");
     $crop = Cloudinary::option_consume($options, "crop");
     $no_html_sizes = $has_layer || !empty($angle) || $crop == "fit" || $crop == "limit" || $responsive_width;
     if (strlen($width) == 0 || $width && ($width == "auto" || floatval($width) < 1 || $no_html_sizes)) {
         unset($options["width"]);
     }
     if (strlen($height) == 0 || $height && (floatval($height) < 1 || $no_html_sizes)) {
         unset($options["height"]);
     }
     $background = Cloudinary::option_consume($options, "background");
     if ($background) {
         $background = preg_replace("/^#/", 'rgb:', $background);
     }
     $color = Cloudinary::option_consume($options, "color");
     if ($color) {
         $color = preg_replace("/^#/", 'rgb:', $color);
     }
     $base_transformations = Cloudinary::build_array(Cloudinary::option_consume($options, "transformation"));
     if (count(array_filter($base_transformations, "is_array")) > 0) {
         $base_transformations = array_map($generate_base_transformation, $base_transformations);
         $named_transformation = "";
     } else {
         $named_transformation = implode(".", $base_transformations);
         $base_transformations = array();
     }
     $effect = Cloudinary::option_consume($options, "effect");
     if (is_array($effect)) {
         $effect = implode(":", $effect);
     }
     $border = Cloudinary::option_consume($options, "border");
     if (is_array($border)) {
         $border_width = Cloudinary::option_get($border, "width", "2");
         $border_color = preg_replace("/^#/", 'rgb:', Cloudinary::option_get($border, "color", "black"));
         $border = $border_width . "px_solid_" . $border_color;
     }
     $flags = implode(Cloudinary::build_array(Cloudinary::option_consume($options, "flags")), ".");
     $dpr = Cloudinary::option_consume($options, "dpr", Cloudinary::config_get("dpr"));
     $duration = Cloudinary::norm_range_value(Cloudinary::option_consume($options, "duration"));
     $start_offset = Cloudinary::norm_range_value(Cloudinary::option_consume($options, "start_offset"));
     $end_offset = Cloudinary::norm_range_value(Cloudinary::option_consume($options, "end_offset"));
     $offset = Cloudinary::split_range(Cloudinary::option_consume($options, "offset"));
     if (!empty($offset)) {
         $start_offset = Cloudinary::norm_range_value($offset[0]);
         $end_offset = Cloudinary::norm_range_value($offset[1]);
     }
     $video_codec = Cloudinary::process_video_codec_param(Cloudinary::option_consume($options, "video_codec"));
     $params = array("a" => $angle, "b" => $background, "bo" => $border, "c" => $crop, "co" => $color, "dpr" => $dpr, "du" => $duration, "e" => $effect, "eo" => $end_offset, "fl" => $flags, "h" => $height, "so" => $start_offset, "t" => $named_transformation, "vc" => $video_codec, "w" => $width);
     $simple_params = array("ac" => "audio_codec", "af" => "audio_frequency", "ar" => "aspect_ratio", "br" => "bit_rate", "cs" => "color_space", "d" => "default_image", "dl" => "delay", "dn" => "density", "f" => "fetch_format", "g" => "gravity", "l" => "overlay", "o" => "opacity", "p" => "prefix", "pg" => "page", "q" => "quality", "r" => "radius", "u" => "underlay", "vs" => "video_sampling", "x" => "x", "y" => "y", "z" => "zoom");
     foreach ($simple_params as $param => $option) {
         $params[$param] = Cloudinary::option_consume($options, $option);
     }
     $param_filter = function ($value) {
         return $value === 0 || $value === '0' || trim($value) == true;
     };
     $params = array_filter($params, $param_filter);
     ksort($params);
     $join_pair = function ($key, $value) {
         return $key . "_" . $value;
     };
     $transformation = implode(",", array_map($join_pair, array_keys($params), array_values($params)));
     $raw_transformation = Cloudinary::option_consume($options, "raw_transformation");
     $transformation = implode(",", array_filter(array($transformation, $raw_transformation)));
     array_push($base_transformations, $transformation);
     if ($responsive_width) {
         $responsive_width_transformation = Cloudinary::config_get("responsive_width_transformation", Cloudinary::$DEFAULT_RESPONSIVE_WIDTH_TRANSFORMATION);
         array_push($base_transformations, Cloudinary::generate_transformation_string($responsive_width_transformation));
     }
     if ($width == "auto" || $responsive_width) {
         $options["responsive"] = true;
     }
     if ($dpr == "auto") {
         $options["hidpi"] = true;
     }
     return implode("/", array_filter($base_transformations));
 }
开发者ID:jbelke,项目名称:cloudinary_php,代码行数:92,代码来源:Cloudinary.php

示例5: update

 function update($public_id, $options = array())
 {
     $resource_type = \Cloudinary::option_get($options, "resource_type", "image");
     $type = \Cloudinary::option_get($options, "type", "upload");
     $uri = array("resources", $resource_type, $type, $public_id);
     $tags = \Cloudinary::option_get($options, "tags");
     $context = \Cloudinary::option_get($options, "context");
     $face_coordinates = \Cloudinary::option_get($options, "face_coordinates");
     $custom_coordinates = \Cloudinary::option_get($options, "custom_coordinates");
     $update_options = array_merge($this->only($options, array("moderation_status", "raw_convert", "ocr", "categorization", "detection", "similarity_search", "auto_tagging", "background_removal")), array("tags" => $tags ? implode(",", \Cloudinary::build_array($tags)) : $tags, "context" => $context ? \Cloudinary::encode_assoc_array($context) : $context, "face_coordinates" => $face_coordinates ? \Cloudinary::encode_double_array($face_coordinates) : $face_coordinates, "custom_coordinates" => $custom_coordinates ? \Cloudinary::encode_double_array($custom_coordinates) : $custom_coordinates));
     return $this->call_api("post", $uri, $update_options, $options);
 }
开发者ID:Hield,项目名称:imagesharing,代码行数:12,代码来源:Api.php


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