-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
35 lines (30 loc) · 1.05 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/**
* Configure Photon to load images from the local filesystem
* instead of fetching from the origin server.
*
* Expects uploads directories to be mounted under at /var/www/photon/uploads/<project-name>/<path>
* and the REQUEST_URI to be /<project-name>/<path>. Skip the <project-name> part if only
* one application is mounted to this container.
*/
define( 'OPTIPNG', '/usr/bin/optipng' );
define( 'PNGQUANT', '/usr/bin/pngquant' );
define( 'PNGCRUSH', '/usr/bin/pngcrush' );
define( 'CWEBP', '/usr/bin/cwebp' );
define( 'JPEGOPTIM', '/usr/bin/jpegoptim' );
define( 'JPEGTRAN', '/usr/bin/jpegtran' );
add_filter(
'override_raw_data_fetch',
function ( $data, $url ) {
$url_parts = parse_url( $url );
if ( ! empty( $url_parts['host'] ) && ! empty( $url_parts['path'] ) ) {
$local_path = sprintf( '/var/www/photon/uploads/%s/%s', $url_parts['host'], ltrim( $url_parts['path'], '/\\' ) );
if ( is_readable( $local_path ) ) {
return file_get_contents( $local_path );
}
}
return false; // Prevent any origin lookups over HTTP.
},
10,
2
);