PHP code example of moritz-sauer-13 / silverstripe-image-optionset

1. Go to this page and download the library: Download moritz-sauer-13/silverstripe-image-optionset 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/ */

    

moritz-sauer-13 / silverstripe-image-optionset example snippets


$field = ImageOptionsetField::create('Template', 'Select a template')
                ->setSource([
                    'sidebar' => [
                        'title' => 'Sidebar page',
                        'image' => '/path/to/sidebar.png'
                    ],
                    'block' => [
                        'title' => 'Block page',
                        'image' => '/path/to/block.png'
                    ]
                ]);

// Use a custom image width and height
$field->setImageWidth(100);
$field->setImageHeight(100);


$field = ImageOptionsetField::create('Template', 'Select a template')
                ->setSource([
                    'sidebar' => '/path/to/sidebar.png'
                    'block' => '/path/to/block.png'
                ]);