本文整理汇总了PHP中Cloudinary类的典型用法代码示例。如果您正苦于以下问题:PHP Cloudinary类的具体用法?PHP Cloudinary怎么用?PHP Cloudinary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cloudinary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCl_upload_url
public function testCl_upload_url()
{
Cloudinary::config_from_url(CLOUDINARY_URL);
$ext = new CloudinaryExtension();
$cloudName = Cloudinary::option_get(Cloudinary::config(), 'cloud_name');
$this->assertEquals('https://api.cloudinary.com/v1_1/' . $cloudName . '/auto/upload', $ext->cl_upload_url());
}
示例2: __construct
/**
* Create a new cloudinary instance.
*
* @param \Illuminate\Config\Repository $config
* @return void
*/
public function __construct(Repository $config)
{
$this->cloudinary = new Cloudinary();
$this->uploader = new Cloudinary\Uploader();
$this->config = $config;
$this->cloudinary->config(array('cloud_name' => $this->config->get('cloudinary::cloudName'), 'api_key' => $this->config->get('cloudinary::apiKey'), 'api_secret' => $this->config->get('cloudinary::apiSecret')));
}
示例3: __construct
/**
* Create a new cloudinary instance.
*
* @param \Illuminate\Config\Repository $config
* @return void
*/
public function __construct(Repository $config, Cloudinary $cloudinary, Cloudinary\Uploader $uploader, Cloudinary\Api $api)
{
$this->cloudinary = $cloudinary;
$this->uploader = $uploader;
$this->api = $api;
$this->config = $config;
$this->cloudinary->config(array('cloud_name' => $this->config->get('cloudder.cloudName'), 'api_key' => $this->config->get('cloudder.apiKey'), 'api_secret' => $this->config->get('cloudder.apiSecret')));
}
示例4: actionCreate
/**
* Creates a new Tweet model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Tweet();
if ($model->load(Yii::$app->request->post())) {
$model->owner = Yii::$app->user->identity->username;
$date = new \DateTime();
$model->timestamp = $date->getTimestamp();
if ($model->save()) {
//Upload images if need be.
$image = UploadedFile::getInstances($model, 'image');
\Cloudinary::config(array("cloud_name" => "dxqmggd5a", "api_key" => "314154111631994", "api_secret" => "KE-AgYwX8ecm8N2omI22RDVmFv4"));
foreach ($image as $file) {
$uploadResult = \Cloudinary\Uploader::upload($file->tempName);
$myConnection = new MediaConnections();
$myConnection->tweet = $model->id;
$myConnection->url = $uploadResult['url'];
$myConnection->timestamp = $model->timestamp;
$myConnection->save();
}
User::findByUsername($model->owner)->createTweet();
return $this->redirect(Yii::$app->request->referrer);
}
}
return $this->render('create', ['model' => $model]);
}
示例5: SetImageSize
public function SetImageSize($width, $height, $crop = 'fill', $gravity = 'faces')
{
CloudinaryFile::get_api();
$options = array('width' => $width, 'height' => $height, 'crop' => $crop, 'quality' => 70, 'gravity' => $gravity, 'secure_distribution' => true, 'secure' => true);
$cloudinaryID = CloudinaryFile::get_public_id($this->CloudinaryURL);
return Cloudinary::cloudinary_url($cloudinaryID . '.' . $this->Format, $options);
}
示例6: init
/**
* Init
* Include the javascript we will need
*
* @return void
* @author Andrew Lowther <andrew.lowther@mademedia.co.uk>
**/
public function init()
{
parent::init();
// Get the config variables we'll need
$config = Config::inst()->get('MediaManager', 'Cloudinary');
// Inject them into the global scope
Requirements::customScript(<<<JS
\t\t\t;(function (window, undefined) {
\t\t\t\twindow.mediamanager = window.mediamanager || {};
\t\t\t\twindow.mediamanager.cloudinary = {
\t\t\t\t\tcloud_name: "{$config['cloud_name']}",
\t\t\t\t\tapi_key: "{$config['api_key']}"
\t\t\t\t}
\t\t\t}/)(window);
JS
);
// Get the base javascript path
$BaseJsPath = MEDIAMANAGER_CORE_PATH . '/javascript';
// Combine the cloudinary files into one super file
Requirements::combine_files('cloudinary.js', array("{$BaseJsPath}/cloudinary/js/load-image.min.js", "{$BaseJsPath}/cloudinary/js/canvas-to-blob.min.js", "{$BaseJsPath}/cloudinary/js/jquery.fileupload.js", "{$BaseJsPath}/cloudinary/js/jquery.ui.widget.js", "{$BaseJsPath}/cloudinary/js/jquery.fileupload-process.js", "{$BaseJsPath}/cloudinary/js/jquery.fileupload-image.js", "{$BaseJsPath}/cloudinary/js/jquery.fileupload-validate.js", "{$BaseJsPath}/cloudinary/js/jquery.cloudinary.js"));
// Same again for our files
Requirements::combine_files('mediamanager.js', array("{$BaseJsPath}/mediamanager/mediamanager.core.js"));
// Set the cloudinary config
\Cloudinary::config($config);
}
示例7: Link
public function Link()
{
CloudinaryFile::get_api();
$options = array('secure_distribution' => true, 'secure' => true);
$cloudinaryID = CloudinaryFile::get_public_id($this->CloudinaryURL);
return Cloudinary::cloudinary_url($cloudinaryID . '.' . $this->Format, $options);
}
示例8: setUp
public function setUp()
{
\Cloudinary::reset_config();
if (!Cloudinary::config_get("api_secret")) {
$this->markTestSkipped('Please setup environment for Upload test to run');
}
$this->url_prefix = Cloudinary::config_get("upload_prefix", "https://api.cloudinary.com");
}
示例9: configureCloudinary
private static function configureCloudinary()
{
try {
Configure::load('CloudinaryPrivate');
\Cloudinary::config(Configure::read('cloudinary'));
} catch (Exception $e) {
CakeLog::notice("Couldn't find Config/CloudinaryPrivate.php file");
}
}
示例10: upload
public function upload($file, $options = array())
{
$options['return_error'] = false;
$ret = Uploader::upload($file, $options);
$preloaded = new PreloadedFile(Cloudinary::signedPreloadedImage($ret));
if ($this->verifyUpload && !$preloaded . is_valid()) {
throw new \Exception("Error! Couldn't verify cloudinary response!");
}
$this->identifier = $preloaded->extendedIdentifier();
}
示例11: test_download_zip_url
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);
}
示例12: __construct
/**
* @DI\InjectParams({
* "cloudName" = @DI\Inject("%cloudinary_name%"),
* "apiKey" = @DI\Inject("%cloudinary_api_key%"),
* "apiSecret" = @DI\Inject("%cloudinary_api_secret%")
* })
*/
public function __construct($cloudName, $apiKey, $apiSecret)
{
$this->cloudName = $cloudName;
\Cloudinary::config([
"cloud_name" => $cloudName,
"api_key" => $apiKey,
"api_secret" => $apiSecret
]);
}
示例13: test_cloudinary_url_from_cloudinary_field
public function test_cloudinary_url_from_cloudinary_field()
{
// should use cloud_name from config
$result = Cloudinary::cloudinary_url(new CloudinaryField("test"));
$this->assertEquals("http://res.cloudinary.com/test123/image/upload/test", $result);
// should ignore signature
$result = Cloudinary::cloudinary_url(new CloudinaryField("test#signature"));
$this->assertEquals("http://res.cloudinary.com/test123/image/upload/test", $result);
$result = Cloudinary::cloudinary_url(new CloudinaryField("rss/imgt/v123/test.jpg"));
$this->assertEquals("http://res.cloudinary.com/test123/rss/imgt/v123/test.jpg", $result);
}
示例14: sendScreenshot
public function sendScreenshot($cloudName, $apiKey, $apiSecret, $authToken)
{
$this->say('Sending image');
// Upload image
Cloudinary::config(array('cloud_name' => $cloudName, 'api_key' => $apiKey, 'api_secret' => $apiSecret));
$result = \Cloudinary\Uploader::upload(realpath(dirname(__FILE__) . '/tests/_output/InstallNenoCest.installNeno.fail.png'));
$this->say('Image sent');
$this->say('Creating Github issue');
$client = new \Github\Client();
$client->authenticate($authToken, \Github\Client::AUTH_HTTP_TOKEN);
$client->api('issue')->create('Jensen-Technologies', 'neno', array('title' => 'Test error', 'body' => '![Screenshot](' . $result['secure_url'] . ')'));
}
示例15: wppa_load_cloudinary
function wppa_load_cloudinary()
{
if (get_option('wppa_cdn_service', 'nil') != 'cloudinary') {
return;
}
require_once 'cloudinary/src/Cloudinary.php';
require_once 'cloudinary/src/Uploader.php';
require_once 'cloudinary/src/Api.php';
\Cloudinary::config(array("cloud_name" => get_option('wppa_cdn_cloud_name'), "api_key" => get_option('wppa_cdn_api_key'), "api_secret" => get_option('wppa_cdn_api_secret')));
global $wppa_cloudinary_api;
$wppa_cloudinary_api = new \Cloudinary\Api();
}