public function direct_upload($fieldName, $options = array())
 {
     $modelKey = $this->model();
     $fieldKey = $this->field();
     $options = @$options["cloudinary"] ? $options["cloudinary"] : array();
     return \cl_image_upload_tag("data[" . $modelKey . "][" . $fieldKey . "]", $options);
 }
Пример #2
0
 function cl_unsigned_image_upload_tag($field, $upload_preset, $options = array())
 {
     return cl_image_upload_tag($field, array_merge($options, array("unsigned" => TRUE, "upload_preset" => $upload_preset)));
 }
Пример #3
0
 public function test_upload_tag()
 {
     $pattern = "/<input class='cloudinary-fileupload' " . "data-cloudinary-field='image' " . "data-form-data='{\"timestamp\":\\d+,\"signature\":\"\\w+\",\"api_key\":\"a\"}' " . "data-url='http[^']+\\/v1_1\\/test123\\/auto\\/upload' " . "name='file' type='file'\\/>/";
     $this->assertRegExp($pattern, cl_upload_tag('image'));
     $this->assertRegExp($pattern, cl_image_upload_tag('image'));
     $pattern = "/<input class='cloudinary-fileupload' " . "data-cloudinary-field='image' " . "data-form-data='{\"timestamp\":\\d+,\"signature\":\"\\w+\",\"api_key\":\"a\"}' " . "data-max-chunk-size='5000000' " . "data-url='http[^']+\\/v1_1\\/test123\\/auto\\/upload_chunked' " . "name='file' type='file'\\/>/";
     $this->assertRegExp($pattern, cl_upload_tag('image', array('chunk_size' => 5000000)));
     $pattern = "/<input class='classy cloudinary-fileupload' " . "data-cloudinary-field='image' " . "data-form-data='{\"timestamp\":\\d+,\"signature\":\"\\w+\",\"api_key\":\"a\"}' " . "data-url='http[^']+\\/v1_1\\/test123\\/auto\\/upload' " . "name='file' type='file'\\/>/";
     $this->assertRegExp($pattern, cl_upload_tag('image', array("html" => array('class' => 'classy'))));
 }
Пример #4
0
 public function test_cl_image_upload_tag()
 {
     Cloudinary::config(array("cloud_name" => "test123", "secure_distribution" => NULL, "private_cdn" => FALSE, "api_key" => "1234"));
     $tag = cl_image_upload_tag("image", array("public_id" => "hello", "html" => array("class" => "uploader")));
     $this->assertRegExp("#<input class='uploader cloudinary-fileupload' data-cloudinary-field='image' data-form-data='{\"timestamp\":\\d+,\"public_id\":\"hello\",\"signature\":\"[0-9a-f]+\",\"api_key\":\"1234\"}' data-url='{$this->url_prefix}\\/v1_1\\/test123\\/auto\\/upload' name='file' type='file'\\/>#", $tag);
 }
Пример #5
0
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::config_get("api_key") . Cloudinary::config_get("api_secret")), 0, 10);
    try {
        $api->upload_preset($upload_preset);
    } catch (\Cloudinary\Api\NotFound $e) {
        $api->create_upload_preset(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 
echo !$unsigned;
?>
"><?php 
echo $unsigned ? "Use signed upload" : "Use unsigned upload";
?>
</a>
      </form>
    <!-- status box -->
    <div class="status">
      <h2>Status</h2>
      <span class="status_value">Idle</span>
    </div>