Skip to content
Snippets Groups Projects
Select Git revision
1 result Searching

index.php

Blame
  • index.php 22.90 KiB
    <?php
    
    define( 'PHOTON__ALLOW_ANY_EXTENSION', 1 );
    define( 'PHOTON__ALLOW_QUERY_STRINGS', 2 );
    
    require dirname( __FILE__ ) . '/plugin.php';
    if ( file_exists( dirname( __FILE__ ) . '/../config.php' ) )
    	require dirname( __FILE__ ) . '/../config.php';
    else if ( file_exists( dirname( __FILE__ ) . '/config.php' ) )
    	require dirname( __FILE__ ) . '/config.php';
    
    // Explicit Configuration
    $allowed_functions = apply_filters( 'allowed_functions', array(
    //	'q'           => RESERVED
    //	'zoom'        => global resolution multiplier (argument filter)
    	'h'           => 'setheight',       // done
    	'w'           => 'setwidth',        // done
    	'crop'        => 'crop',            // done
    	'resize'      => 'resize_and_crop', // done
    	'fit'         => 'fit_in_box',      // done
    	'lb'          => 'letterbox',       // done
    	'ulb'         => 'unletterbox',     // compat
    	'filter'      => 'filter',          // compat
    	'brightness'  => 'brightness',      // compat
    	'contrast'    => 'contrast',        // compat
    	'colorize'    => 'colorize',        // compat
    	'smooth'      => 'smooth',          // compat
    ) );
    
    unset( $allowed_functions['q'] );
    
    $allowed_types = apply_filters( 'allowed_types', array(
    	'gif',
    	'jpg',
    	'jpeg',
    	'png',
    ) );
    
    $disallowed_file_headers = apply_filters( 'disallowed_file_headers', array(
    	'8BPS',
    ) );
    
    // Expects a trailing slash
    $tmpdir = apply_filters( 'tmpdir', '/tmp/' );
    $remote_image_max_size = apply_filters( 'remote_image_max_size', 55 * 1024 * 1024 );
    
    /* Array of domains exceptions
     * Keys are domain name
     * Values are bitmasks with the following options:
     * PHOTON__ALLOW_ANY_EXTENSION: Allow any extension (including none) in the path of the URL
     * PHOTON__ALLOW_QUERY_STRINGS: Append the string found in the 'q' query string parameter as the query string of the remote URL
     */
    $origin_domain_exceptions = apply_filters( 'origin_domain_exceptions', array() );
    
    // You can override this by defining it in config.php
    if ( ! defined( 'PHOTON__UPSCALE_MAX_PIXELS' ) )
    	define( 'PHOTON__UPSCALE_MAX_PIXELS', 1000 );
    
    require dirname( __FILE__ ) . '/libjpeg.php';
    
    // Implicit configuration
    if ( file_exists( '/usr/local/bin/optipng' ) )
    	define( 'OPTIPNG', '/usr/local/bin/optipng' );
    else
    	define( 'OPTIPNG', false );
    
    if ( file_exists( '/usr/local/bin/jpegoptim' ) )
    	define( 'JPEGOPTIM', '/usr/local/bin/jpegoptim' );
    else
    	define( 'JPEGOPTIM', false );