PHP code example of rsoury / wp-imgix

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

    

rsoury / wp-imgix example snippets


$image_url = 'https://my-bucket.s3.us-east-1.amazonaws.com/path/to/image.jpg';
$args      = [
	'x'  => '300'
	'y' => '300',
	'fit' => 'crop'
];

$url = imgix_url( $image_url, $args );

add_filter( 'imgix_disable_in_admin', '__return_false' );

add_filter( 'imgix_override_image_downsize', '__return_true' );

add_filter( 'imgix_skip_for_url', function ( $skip, $image_url, $args ) {
	if ( strpos( $image_url, 'original' ) !== false ) {
		return true;
	}

	return $skip;
}, 10, 3 );

add_filter( 'imgix_pre_image_url', function ( $image_url, $args ) {
	if ( rand( 1, 2 ) === 2 ) {
		$image_url = str_replace( WP_IMGIX_URL, WP_IMGIX_URL_2, $image_url );
	}

	return $image_url;
}, 10, 2 );

add_filter( 'imgix_pre_args', function ( $args ) {
	if ( isset( $args['fit'] ) ) {
		$args['fill'] = 'blur';
	}

	return $args;
} );

add_filter( 'imgix_remove_size_attributes', '__return_true' );