本文整理汇总了PHP中Cloudinary::generate_transformation_string方法的典型用法代码示例。如果您正苦于以下问题:PHP Cloudinary::generate_transformation_string方法的具体用法?PHP Cloudinary::generate_transformation_string怎么用?PHP Cloudinary::generate_transformation_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cloudinary
的用法示例。
在下文中一共展示了Cloudinary::generate_transformation_string方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: zip_download_url
public static function zip_download_url($tag, $options = array())
{
$params = array("timestamp" => time(), "tag" => $tag, "transformation" => \Cloudinary::generate_transformation_string($options));
$params = Cloudinary::sign_request($params, $options);
return Cloudinary::cloudinary_api_url("download_tag.zip", $options) . "?" . http_build_query($params);
}
示例4: cloudinary_url
public static function cloudinary_url($source, &$options = array())
{
$type = Cloudinary::option_consume($options, "type", "upload");
if ($type == "fetch" && !isset($options["fetch_format"])) {
$options["fetch_format"] = Cloudinary::option_consume($options, "format");
}
$transformation = Cloudinary::generate_transformation_string($options);
$resource_type = Cloudinary::option_consume($options, "resource_type", "image");
$version = Cloudinary::option_consume($options, "version");
$format = Cloudinary::option_consume($options, "format");
$cloud_name = Cloudinary::option_consume($options, "cloud_name", Cloudinary::config_get("cloud_name"));
if (!$cloud_name) {
throw new InvalidArgumentException("Must supply cloud_name in tag or in configuration");
}
$secure = Cloudinary::option_consume($options, "secure", Cloudinary::config_get("secure"));
$private_cdn = Cloudinary::option_consume($options, "private_cdn", Cloudinary::config_get("private_cdn"));
$secure_distribution = Cloudinary::option_consume($options, "secure_distribution", Cloudinary::config_get("secure_distribution"));
$cdn_subdomain = Cloudinary::option_consume($options, "cdn_subdomain", Cloudinary::config_get("cdn_subdomain"));
$cname = Cloudinary::option_consume($options, "cname", Cloudinary::config_get("cname"));
$original_source = $source;
if (!$source) {
return $original_source;
}
if (preg_match("/^https?:\\//i", $source)) {
if ($type == "upload" || $type == "asset") {
return $original_source;
}
$source = Cloudinary::smart_escape($source);
} else {
if ($format) {
$source = $source . "." . $format;
}
}
if ($secure && !$secure_distribution) {
if ($private_cdn) {
throw new InvalidArgumentException("secure_distribution not defined");
} else {
$secure_distribution = Cloudinary::SHARED_CDN;
}
}
if ($secure) {
$prefix = "https://" . $secure_distribution;
} else {
$crc = crc32($source);
if ($crc < 0) {
$crc += 4294967296;
}
$subdomain = $cdn_subdomain ? "a" . (fmod($crc, 5) + 1) . "." : "";
$host = $cname ? $cname : ($private_cdn ? $cloud_name . "-" : "") . "res.cloudinary.com";
$prefix = "http://" . $subdomain . $host;
}
if (!$private_cdn) {
$prefix .= "/" . $cloud_name;
}
return preg_replace("/([^:])\\/+/", "\$1/", implode("/", array($prefix, $resource_type, $type, $transformation, $version ? "v" . $version : "", $source)));
}
示例5: transformation_string
protected function transformation_string($transformation)
{
return is_string($transformation) ? $transformation : Cloudinary::generate_transformation_string($transformation);
}
示例6: test_translate_if
/**
* should support and translate operators: '=', '!=', '<', '>', '<=', '>=', '&&', '||'
* and variables: width, height, pages, faces, aspect_ratio
*/
public function test_translate_if()
{
$allOperators = 'if_' . 'w_eq_0_and' . '_h_ne_0_or' . '_ar_lt_0_and' . '_pc_gt_0_and' . '_fc_lte_0_and' . '_w_gte_0' . ',e_grayscale';
$condition = "width = 0 && height != 0 || aspect_ratio < 0 && page_count > 0 and face_count <= 0 and width >= 0";
$options = array("if" => $condition, "effect" => "grayscale");
$transformation = Cloudinary::generate_transformation_string($options);
$this->assertEquals($allOperators, $transformation);
$this->assertEquals(array(), $options);
$options = array("if" => "aspect_ratio > 0.3 && aspect_ratio < 0.5", "effect" => "grayscale");
$transformation = Cloudinary::generate_transformation_string($options);
$this->assertEquals("if_ar_gt_0.3_and_ar_lt_0.5,e_grayscale", $transformation);
$this->assertEquals(array(), $options);
}
示例7: prepare_streaming_profile_params
/**
* Prepare streaming profile parameters for API calls
* @param $options the options passed to the API
* @return array A single profile parameters
*/
protected function prepare_streaming_profile_params($options)
{
$params = $this->only($options, array("display_name"));
if (isset($options['representations'])) {
$array_map = array_map(function ($representation) {
return array("transformation" => \Cloudinary::generate_transformation_string($representation));
}, $options['representations']);
$params["representations"] = json_encode($array_map);
}
return $params;
}