public function transformImage(Image $image, Transformation $transformation = null)
 {
     if ($transformation === null) {
         $transformation = $this->configuration->getDefaultTransformation();
     }
     return Image::fromPath(\cloudinary_url($image->getId(), $transformation->build()));
 }
 public function url($options = array())
 {
     if (!$this->identifier) {
         // TODO: Error?
         return;
     }
     return cloudinary_url($this, $options);
 }
Esempio n. 3
0
function show_image($img, $options = array(), $caption = '')
{
    $options['format'] = $img['format'];
    $transformation_url = cloudinary_url($img['public_id'], $options);
    echo '<div class="item">';
    echo '<div class="caption">' . $caption . '</div>';
    echo '<a href="' . $img['url'] . '" target="_blank">' . cl_image_tag($img['public_id'], $options) . '</a>';
    echo '<div class="public_id">' . $img['public_id'] . '</div>';
    echo '<div class="link"><a target="_blank" href="' . $transformation_url . '">' . $transformation_url . '</a></div>';
    echo '</div>';
}
function show_image($img, $options = array(), $caption = "")
{
    $options["format"] = $img["format"];
    $transformation_url = cloudinary_url($img["public_id"], $options);
    echo "<div class='item'>";
    echo "<div class='caption'>" . $caption . "</div>";
    echo "<a href='" . $img["url"] . "' target='_blank'>" . cl_image_tag($img["public_id"], $options) . "</a>";
    echo "<div class='public_id'>" . $img["public_id"] . "</div>";
    echo "<div class='link'><a target='_blank' href='" . $transformation_url . "'>" . $transformation_url . "</a></div>";
    echo "</div>";
}
Esempio n. 5
0
 static function url($media, $style = array(), $default = NULL)
 {
     if ($media && get_class($media) == 'App\\Models\\Media' && isset($media->public_id)) {
         return cloudinary_url($media->public_id, $style);
     } else {
         if ($default && is_string($default)) {
             return cloudinary_url($default, $style);
         }
     }
     return FALSE;
 }
 public function resolve(File $file)
 {
     $parametersArray = $this->generateParametersArray($file);
     $cloudinaryResponse = $file->getMeta('cloudinary_response');
     $parametersArray['secure'] = true;
     $parametersArray['version'] = $cloudinaryResponse['version'];
     if ($cloudinaryResponse['resource_type'] === 'image') {
         $parametersArray['format'] = $cloudinaryResponse['format'];
     }
     return cloudinary_url($cloudinaryResponse['public_id'], $parametersArray);
 }
Esempio n. 7
0
 /**
  * Get media path
  */
 public function get_path($style = self::STYLE_ORIGINAL)
 {
     //  	if ($this->public_id && $style != self::STYLE_ROOT) {
     return cloudinary_url($this->public_id, $this->styles[$style]);
     //  	}
     /*
       	if (isset($this->id)) {
       		
     		$path = MEDIA_PATH.$this->id;
     		
     		if (!in_array($style,array(self::STYLE_ORIGINAL,self::STYLE_ROOT))) {
     			$cache_path = CACHE_PATH.$this->id.'_'.$style;
     			if ($this->config->item('cache_media') && file_exists(ROOT_PATH.$cache_path)) {
     				log_message('debug','Using image cache: '.$cache_path);
     				$path = $cache_path;
     			} else {
     				$style = $this->styles[$style];
     				
     				$config['image_library'] = 'gd2';
     				$config['source_image']	= ROOT_PATH.$path;
     				$config['new_image'] = ROOT_PATH.CACHE_PATH;
     				$config['maintain_ratio'] = FALSE;
     				$config['width'] =  $style['width'];
     				$config['height'] = $style['height'];
     				
     				$this->load->library('image_lib', $config); 
     
     				if ($this->image_lib->resize()) {
     					rename(ROOT_PATH.CACHE_PATH.$this->id,$cache_path);
     					log_message('debug','Creating image cache: '.$cache_path);
     					$path = $cache_path;
     				} else {
     					if (file_exists(ROOT_PATH.$cache_path)) unlink($cache_path);
     					log_message('error','Error creating image cache: '.$this->image_lib->display_errors());
     				}
     			}
     		}
     		if ($style == self::STYLE_ROOT) return ROOT_PATH.$path;
     		else return site_url($path);
     		
     	} else return false;*/
 }
Esempio n. 8
0
 public function getItem()
 {
     $state = $this->getState();
     if ($state->container) {
         $container = $this->getService('com://admin/cloudinary.model.accounts')->slug($state->container)->getItem();
     } else {
         // Select default account
         $container = $this->getService('com://admin/cloudinary.model.accounts')->default(1)->getItem();
     }
     Cloudinary::config(array('cloud_name' => $container->cloud_name, 'api_key' => $container->api_key, 'api_secret' => $container->api_secret));
     // Force the path to a string so object with __toString() function will work
     $this->set('path', (string) $state->path);
     if (parent::getItem()->isNew()) {
         if (!$state->type) {
             $image = \Cloudinary\Uploader::upload(JPATH_FILES . '/' . $state->path);
         }
         $this->_item = $this->getRow()->setData(array('public_id' => $state->type ? $state->path : $image['public_id'], 'path' => $state->path, 'url' => $state->type ? '' : $image['url'], 'format' => $state->type ? '' : $image['format'], 'cloudinary_account_id' => $container->id));
         $this->_item->save();
     }
     if ($state->flags) {
         if (is_array($state->flags)) {
             $state->flags = implode('.', $state->flags);
         }
     }
     $file = $state->type ? $this->_item->public_id : $this->_item->public_id . '.' . $this->_item->format;
     $this->_item->setData(array('url' => cloudinary_url($file, $state->toArray())));
     if ($state->cache) {
         $this->_item->setData(array('url' => $this->_item->getImage($this->_item->url, $state->toArray())));
     }
     if ($state->getsize) {
         $curl = curl_init($this->_item->url);
         curl_setopt_array($curl, array(CURLOPT_HTTPHEADER => array('Range: bytes=0-32768'), CURLOPT_RETURNTRANSFER => 1));
         $image = imagecreatefromstring(curl_exec($curl));
         $this->_item->setData(array('width' => imagesx($image), 'height' => imagesy($image)));
         curl_close($curl);
     }
     $this->_item->setData(array('attribs' => KHelperArray::toString($state->attribs)));
     return $this->_item;
 }
         </a>
       
       <div class="less_info">
         <a href="#" class="toggle_info">More transformations...</a>
       </div>
       
       <div class="more_info">
         <a href="#" class="toggle_info">Hide transformations...</a>
         <table class="thumbnails">
           <?php 
 $thumbs = array(array("crop" => "fill", "radius" => 10), array("crop" => "scale"), array("crop" => "fit", "format" => "png"), array("crop" => "thumb", "gravity" => "face"), array("override" => true, "format" => "png", "angle" => 20, "transformation" => array("crop" => "fill", "gravity" => "north", "width" => 150, "height" => 150, "effect" => "sepia")));
 foreach ($thumbs as $params) {
     $merged_params = array_merge(\Cloudinary::option_consume($params, "override") ? array() : $thumbs_params, $params);
     echo "<td>";
     echo "<div class='thumbnail_holder'>";
     echo "<a target='_blank' href='" . cloudinary_url($photo["public_id"], $merged_params) . "'>" . cl_image_tag($photo["public_id"], $merged_params) . "</a>";
     echo "</div>";
     echo "<br/>";
     \PhotoAlbum\array_to_table($merged_params);
     echo "</td>";
 }
 ?>
           
         </table>
         
         <div class="note">             	
         	Take a look at our documentation of <a href="http://cloudinary.com/documentation/image_transformations" target="_blank">Image Transformations</a> for a full list of supported transformations.
         </div>	
       </div>
     </div>
   <?php 
 /**
  * Test the image fetch
  *
  * @return void
  * @author Andrew Lowther <*****@*****.**>
  **/
 public function testCloudinaryImageFetch()
 {
     $mediaItem = DataObject::get_by_id('MediaItem', 1);
     $image = cloudinary_url('test.png');
     $this->assertTrue($image === sprintf('http://res.cloudinary.com/%s/image/upload/test.png', $this->config['cloud_name']));
 }
Esempio n. 11
0
 public function get($data, array $options = array())
 {
     $image = $data == null ? NULL : implode('.', $data);
     return cloudinary_url($image, $options);
 }
 /**
  * @inheritdoc
  */
 public function getFileUrl(File $file, array $options)
 {
     return cloudinary_url($this->createFilePath($file), $options);
 }
Esempio n. 13
0
 public function test_explicit()
 {
     $result = Cloudinary\Uploader::explicit("cloudinary", array("type" => "twitter_name", "eager" => array("crop" => "scale", "width" => "2.0")));
     $url = cloudinary_url("cloudinary", array("type" => "twitter_name", "crop" => "scale", "width" => "2.0", "format" => "png", "version" => $result["version"]));
     $this->assertEquals($result["eager"][0]["url"], $url);
 }
Esempio n. 14
0
<?php

header("Access-Control-Allow-Origin: *");
require 'main.php';
?>
<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="utf-8">
    <title>PhotoAlbum - Upload page2</title>

	<link href="style.css" media="all" rel="stylesheet" />

    <link rel="shortcut icon"
     href="<?php 
echo cloudinary_url("http://cloudinary.com/favicon.png", array("type" => "fetch"));
?>
" />

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.12.5/js/vendor/jquery.ui.widget.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.12.5/js/jquery.iframe-transport.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.12.5/js/jquery.fileupload.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/cloudinary-jquery-file-upload/2.1.2/cloudinary-jquery-file-upload.js"></script>
    <?php 
echo cloudinary_js_config();
?>
  </head>
  
  <body>
  	
 /**
  * @inheritdoc
  */
 public function getImageUrl($path, array $options)
 {
     return cloudinary_url($path, $options);
 }
 /**
  * Generate the <amp-img srcset=""> Attribute
  *
  * @param string $src the original source image
  * @return string
  */
 private function generateSrcset($src)
 {
     return implode(', ', [cloudinary_url($src, ['width' => 700, 'crop' => 'limit', 'sign_url' => true, 'type' => 'fetch', 'effect' => 'sharpen']) . ' 700w', cloudinary_url($src, ['width' => 465, 'crop' => 'limit', 'sign_url' => true, 'type' => 'fetch', 'effect' => 'sharpen']) . ' 465w']);
 }
 /**
  * Read a file as a stream.
  *
  * @param string $path
  *
  * @return array|false
  */
 public function readStream($path)
 {
     try {
         $stream = fopen(cloudinary_url($path), 'r');
     } catch (Exception $e) {
         return false;
     }
     return compact('stream', 'path');
 }
 public function getAssetUrl(AssetFileModel $asset, $options)
 {
     $publicId = $this->getAssetHandle($asset);
     $url = cloudinary_url($publicId, $options);
     return $url;
 }
Esempio n. 19
0
 /**
  * Generate cloudinary image url for a cloud image
  * @param ImagesCloud [$objCloudImage] A cloud image object
  * @param integer [$intWidth] Image width
  * @param integer [$intHeight] Image height
  * @param bool [$limitSize] True to get image by its original dimension if
  * it is smaller than the requested dimension
  * @return string Cloudinary image url
  */
 public function getCloudImage($objCloudImage, $intWidth, $intHeight, $limitSize = false)
 {
     $this->init();
     \Cloudinary::config(array("cloud_name" => $objCloudImage->cloudinary_cloud_name, "api_key" => "", "api_secret" => ""));
     $arrOptions = array();
     if ($limitSize) {
         /* The limit mode is used for creating an image that does not exceed
         			the given width or height. If the original image is smaller than
         			the given limits, the generated image is identical to the original
         			one. If the original is bigger than the given limits, it will be
         			resized while retaining original proportions
         			*/
         $crop = "limit";
     } else {
         /* Resize the image to fill the given width & height while retaining
         			original proportions.
         			*/
         $crop = "pad";
     }
     if ($intWidth > 0 && $intHeight > 0) {
         $arrOptions = array("width" => $intWidth, "height" => $intHeight, "crop" => $crop);
     }
     if (!empty(Yii::app()->params['IMAGE_BACKGROUND'])) {
         $arrOptions['background'] = "rgb:" . str_replace("#", "", Yii::app()->params['IMAGE_BACKGROUND']);
     }
     if (!empty(Yii::app()->params['IMAGE_SHARPEN'])) {
         $arrOptions['sharpen'] = Yii::app()->params['IMAGE_SHARPEN'];
     }
     if (!empty(Yii::app()->params['IMAGE_QUALITY'])) {
         $arrOptions['quality'] = Yii::app()->params['IMAGE_QUALITY'];
     }
     $url = cloudinary_url($objCloudImage->cloudinary_public_id . "." . Yii::app()->params['IMAGE_FORMAT'], $arrOptions);
     //we remove schema so either http or httpd will work
     $url = str_replace("http:", "", str_replace("https:", "", $url));
     return $url;
 }