PHP code example of codeinwp / optimole-sdk

1. Go to this page and download the library: Download codeinwp/optimole-sdk 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/ */

    

codeinwp / optimole-sdk example snippets


use Optimole\Sdk\Optimole;

Optimole::init('your-api-key', $options);

use Optimole\Sdk\Optimole;

$image = Optimole::image('https://example.com/image.jpg')->quality(80)->resize('crop');

echo $image->getUrl();
echo (string) $image;

use Optimole\Sdk\Optimole;

$imageId = Optimole::offload()->uploadImage('path/to/image.jpg', 'https://url/to/image.jpg');

use Optimole\Sdk\Optimole;

$imageUrl = Optimole::offload()->getImageUrl($imageId);