PHP code example of picperf / wordpress

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

    

picperf / wordpress example snippets


// Transform all images (default).
define('PICPERF_TRANSFORMATION_SCOPE', 'ALL');

// Only transform `the_content` images.
define('PICPERF_TRANSFORMATION_SCOPE', 'CONTENT');

// Transform no images.
define('PICPERF_TRANSFORMATION_SCOPE', null);



// Include no images in sitemap (default).
define('PICPERF_ADD_SITEMAP_PATH', null);

// Only add `the_content` images to sitemap.
define('PICPERF_ADD_SITEMAP_PATH', 'CONTENT');

// Add all image so sitemap.
define('PICPERF_ADD_SITEMAP_PATH', 'ALL');



define('PICPERF_DISABLE_SITEMAP', true);

$transformedUrl = PicPerf\transformUrl("https://example.com/my-image.jpg");

// https://picperf.io/https://example.com/my-image.jpg