PHP code example of level51 / silverstripe-cloudinary

1. Go to this page and download the library: Download level51/silverstripe-cloudinary library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

level51 / silverstripe-cloudinary example snippets



private static $has_one = [
    'Image' => \Level51\Cloudinary\Image::class
];

private static $has_many = [
    'Images' => Image::class
];

public function getCMSFields() {
	$fields = parent::getCMSFields();
	
	$fields->addFieldsToTab(
		'Root.Main',
		[
			\Level51\Cloudinary\UploadField::create('Image', $this->fieldLabel('Image')),
				// ->setRatio(16 / 9)
				// ->disableCropping()
				// ->setFolderName('path/to/destination')
				// ->setAllowedExtensions(['jpg'])
			\Level51\Cloudinary\MultiUploadField::create('Images', $this->fieldLabel('Images'))
				// ->setAllowedMaxFileNumber(5)
		]
	);
	
	return $fields;
}

// In templates
$Image

// With transormations
$Image.FillMax(1920,1080)

// With effect filters
$Image.Grayscale.FillMax(1920,1080)