Beispiel #1
0
 /**
  * Return url for javascript widget.
  * If no version is provided method will use default(current) version
  *
  * @param string $version Version of Uploadcare.com widget
  * @return string
  */
 public function getScriptSrc($version = null)
 {
     if (!$version) {
         $version = self::version;
     }
     return sprintf($this->api->getCdnUri() . '/widget/%s/uploadcare/uploadcare.full.min.js', $version);
 }
Beispiel #2
0
 /**
  * Return url for javascript widget.
  * If no version is provided method will use default(current) version
  *
  * @param string $version Version of Uploadcare.com widget
  * @return string
  */
 public function getScriptSrc($version = null, $full = true)
 {
     if (!$version) {
         $version = self::version;
     }
     if ($full) {
         $tail = "uploadcare.full.min.js";
     } else {
         $tail = "uploadcare.min.js";
     }
     return sprintf($this->api->getCdnUri() . '/widget/%s/uploadcare/' . $tail, $version);
 }
Beispiel #3
0
 /**
  * Get url of original image
  *
  * @param string $postfix
  * @return string
  */
 public function getUrl($postfix = null)
 {
     $url = sprintf('%s/%s/', $this->api->getCdnUri(), $this->uuid);
     if ($this->default_effects) {
         $url = sprintf('%s-/%s', $url, $this->default_effects);
     }
     if ($this->filename && $postfix === null) {
         $postfix = $this->filename;
     }
     $operations = array();
     foreach ($this->operations as $i => $operation_item) {
         $part = array();
         foreach (array_keys($operation_item) as $operation_type) {
             $operation_params = $operation_item[$operation_type];
             $part[] = $operation_type;
             switch ($operation_type) {
                 case 'crop':
                     $part = $this->__addPartSize($part, $operation_params);
                     $part = $this->__addPartCenter($part, $operation_params);
                     $part = $this->__addPartFillColor($part, $operation_params);
                     break;
                 case 'resize':
                     $part = $this->__addPartSize($part, $operation_params);
                     break;
                 case 'scale_crop':
                     $part = $this->__addPartSize($part, $operation_params);
                     $part = $this->__addPartCenter($part, $operation_params);
                     break;
                 case 'effect':
                     $part = $this->__addPartEffect($part, $operation_params);
                     break;
                 case 'preview':
                     $part = $this->__addPartSize($part, $operation_params);
                     break;
                 case 'custom':
                     $part = array($operation_params);
                     break;
             }
             $part_str = join('/', $part);
             $operations[] = $part_str;
         }
     }
     if (count($operations)) {
         $operations_part = join('/-/', $operations);
         return $url . '-/' . $operations_part . '/' . $postfix;
     } else {
         return $url . $postfix;
     }
 }