Ejemplo n.º 1
0
 public function test_download_zip_url()
 {
     $result = \Cloudinary::download_zip_url(array("tags" => $this->tag));
     $file = tempnam("tmp", "zip");
     file_put_contents($file, file_get_contents($result));
     $zip = new \ZipArchive();
     $zip->open($file);
     $this->assertEquals(2, $zip->numFiles);
     unlink($file);
 }
 public function testCloudinaryUrlFromCloudinaryField()
 {
     // [<resource_type>/][<image_type>/][v<version>/]<public_id>[.<format>][#<signature>]
     // should use cloud_name from config
     $result = Cloudinary::cloudinaryUrl(new CloudinaryField('test'));
     $this->assertEquals('http://res.cloudinary.com/test123/image/upload/test', $result);
     // should ignore signature
     $result = Cloudinary::cloudinaryUrl(new CloudinaryField('test#signature'));
     $this->assertEquals('http://res.cloudinary.com/test123/image/upload/test', $result);
     $result = Cloudinary::cloudinaryUrl(new CloudinaryField('rss/imgt/v123/test.jpg'));
     $this->assertEquals('http://res.cloudinary.com/test123/rss/imgt/v123/test.jpg', $result);
 }
Ejemplo n.º 3
0
 echo "<div class='public_id'>" . $photo["public_id"] . "</div>";
 echo cl_image_tag($photo["public_id"], array_merge($thumbs_params, array("crop" => "fill")));
 ?>
         </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\Cloudinary::optionConsume($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>	
Ejemplo n.º 4
0
    <?php 
$unsigned = isset($_GET["unsigned"]) && $_GET["unsigned"] == "1";
?>
    <div id='direct_upload'>
      <h1>Direct <?php 
if ($unsigned) {
    echo "unsigned ";
}
?>
upload from the browser</h1>
      <form>
      <?php 
if ($unsigned) {
    # For the sake of simplicity of the sample site, we generate the preset on the fly. It only needs to be created once, in advance.
    $api = new \Cloudinary\Api();
    $upload_preset = "sample_" . substr(sha1(\Cloudinary\Cloudinary::configGet("api_key") . \Cloudinary\Cloudinary::configGet("api_secret")), 0, 10);
    try {
        $api->uploadPreset($upload_preset);
    } catch (\Cloudinary\Api\NotFound $e) {
        $api->createUploadPreset(array("name" => $upload_preset, "unsigned" => TRUE, "folder" => "preset_folder"));
    }
    # The callback URL is set to point to an HTML file on the local server which works-around restrictions
    # in older browsers (e.g., IE) which don't full support CORS.
    echo cl_unsigned_image_upload_tag('test', $upload_preset, array("tags" => "direct_photo_album", "callback" => $cors_location, "html" => array("multiple" => true)));
} else {
    # The callback URL is set to point to an HTML file on the local server which works-around restrictions
    # in older browsers (e.g., IE) which don't full support CORS.
    echo cl_image_upload_tag('test', array("tags" => "direct_photo_album", "callback" => $cors_location, "html" => array("multiple" => true)));
}
?>
      <a href="?unsigned=<?php 
Ejemplo n.º 5
0
<?php

require 'main.php';
# You can add here your custom verification code
# Check for a valid Cloudinary response
$api_secret = \Cloudinary\Cloudinary::configGet("api_secret");
if (!$api_secret) {
    throw new \InvalidArgumentException("Must supply api_secret");
}
$existing_signature = \Cloudinary\Cloudinary::optionConsume($_POST, "signature");
$to_sign = array('public_id' => $_POST['public_id'], 'version' => $_POST['version']);
$calculated_signature = \Cloudinary\Cloudinary::apiSignRequest($to_sign, $api_secret);
if ($existing_signature == $calculated_signature) {
    # Create a model record using the data received (best practice is to save locally
    # only data needed for reaching the image on Cloudinary - public_id and version;
    # and fields that might be needed for your application (e.g.,), width, height)
    $photo = \PhotoAlbum\create_photo_model($_POST);
} else {
    error_log("Received signature verficiation failed (" . $existing_signature . " != " . $calculated_signature . "). data: " . \PhotoAlbum\ret_var_dump($_POST));
}