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


PHP Cloudinary::smart_escape方法代码示例

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


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

示例1: 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)));
 }
开发者ID:vanbungkring,项目名称:24custom,代码行数:56,代码来源:cloudinary_api.php

示例2: finalize_source

 private static function finalize_source($source, $format, $url_suffix)
 {
     $source = preg_replace('/([^:])\\/\\//', '$1/', $source);
     if (preg_match('/^https?:\\//i', $source)) {
         $source = Cloudinary::smart_escape($source);
         $source_to_sign = $source;
     } else {
         $source = Cloudinary::smart_escape(rawurldecode($source));
         $source_to_sign = $source;
         if (!empty($url_suffix)) {
             if (preg_match('/[\\.\\/]/i', $url_suffix)) {
                 throw new InvalidArgumentException("url_suffix should not include . or /");
             }
             $source = $source . '/' . $url_suffix;
         }
         if (!empty($format)) {
             $source = $source . '.' . $format;
             $source_to_sign = $source_to_sign . '.' . $format;
         }
     }
     return array("source" => $source, "source_to_sign" => $source_to_sign);
 }
开发者ID:ShanksGtr,项目名称:AdminerTest,代码行数:22,代码来源:Cloudinary.php

示例3: 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"));
     $shorten = Cloudinary::option_consume($options, "shorten", Cloudinary::config_get("shorten"));
     $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 {
         $source = Cloudinary::smart_escape(rawurldecode($source));
         if ($format) {
             $source = $source . "." . $format;
         }
     }
     $shared_domain = !$private_cdn;
     if ($secure) {
         if (!$secure_distribution || $secure_distribution == Cloudinary::OLD_AKAMAI_SHARED_CDN) {
             $secure_distribution = $private_cdn ? $cloud_name . "-res.cloudinary.com" : Cloudinary::SHARED_CDN;
         }
         $shared_domain = $shared_domain || $secure_distribution == Cloudinary::SHARED_CDN;
         $prefix = "https://" . $secure_distribution;
     } else {
         $subdomain = $cdn_subdomain ? "a" . ((crc32($source) % 5 + 5) % 5 + 1) . "." : "";
         $host = $cname ? $cname : ($private_cdn ? $cloud_name . "-" : "") . "res.cloudinary.com";
         $prefix = "http://" . $subdomain . $host;
     }
     if ($shared_domain) {
         $prefix .= "/" . $cloud_name;
     }
     if ($shorten && $resource_type == "image" && $type == "upload") {
         $resource_type = "iu";
         $type = "";
     }
     if (strpos($source, "/") && !preg_match("/^https?:\\//", $source) && !preg_match("/^v[0-9]+/", $source) && empty($version)) {
         $version = "1";
     }
     return preg_replace("/([^:])\\/+/", "\$1/", implode("/", array($prefix, $resource_type, $type, $transformation, $version ? "v" . $version : "", $source)));
 }
开发者ID:msayagh,项目名称:Quercus-source-code-Maven,代码行数:59,代码来源:Cloudinary.php


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