Configuration

Basic Configuration

The following extended configuration is completely optional. This will allow you to change the default settings for the CE Image plugin directly from your config.php file. This also makes upgrading the plugin easier if you are not using the default ($cache_dir and $remote_dir) cache directory values. Please note that you don’t need all of the settings. You may choose to only copy one or more as needed.

ExpressionEngine® 2.x

Simply copy what you need from the following code and paste it in your system/expressionengine/config/config.php file after the line that reads, // END EE config items.

/*
|-----------------------------
| CE Image Basic Config Items
|-----------------------------
|
| The following items are for use with CE Image. They are all optional,
| as the defaults in the actual plugin will be used if not specified below.
*/

/*
| The *relative path* (to your web root) of the directory to cache images
| in. This path will override the $cache_dir variable in the plugin file,
| and can optionally be overridden via the cache_dir= plugin parameter.
*/

$config['ce_image_cache_dir'] = '/images/made/';

/*
| The *relative path* (to your web root) of the folder to download remote
| images. This path will override the $remote_dir variable in the plugin
| file, and can optionally be overridden via the remote_dir= plugin
| parameter.
*/

$config['ce_image_remote_dir'] = '/images/remote/';

/*
| The ce_image_memory_limit sets the amount of memory (in megabytes) PHP can
| use for the script (64 is generally sufficient). If the PHP memory_limit
| is set to a greater value, then this setting will not override it.
*/

$config['ce_image_memory_limit'] = 64;

/*
| If the plugin cannot determine the last change date of a remote image,
| wait this long (in minutes) before re-downloading the image:
*/

$config['ce_image_remote_cache_time'] = 1440;

/*
| The default quality to save a jpg/jpeg file. The quality can range from
| 0 (lowest) to 100 (highest) and should be a whole number.
*/

$config['ce_image_quality'] = 100;

/*
| You can optionally run images that are downloaded from remote sites
| through an XSS filter. The filter sometimes gives false negatives though.
| If you know and trust the source of your images, you can disable the
| filter by default. You can always override this per tag via the
| disable_xss_check= parameter.
*/

$config['ce_image_disable_xss_check'] = 'yes';

/*
| By default, CE Image will add in width and height attributes to the image
| tags it generates when using the ce_img:single tag. If you would like to
| disable this globally, you can use this setting. You can also change this
| on a per tag basis using the add_dims= parameter. The default is "yes".
*/

$config['ce_image_add_dims'] = 'no';
// END CE Image basic config items

ExpressionEngine® 1.x

Simply copy what you need from the following code and paste it in your system/config.php file below the other config items, but above the ?>.

$conf['ce_image_cache_dir'] = "/images/made/";
$conf['ce_image_remote_dir'] = "/images/remote/";
$conf['ce_image_memory_limit'] = "64";
$conf['ce_image_remote_cache_time'] = "1440";
$conf['ce_image_quality'] = "100";

Advanced Configuration

It would probably be fair to say that CE Image works out-of-the-box about 98% to 99% of the time. About 1% to 2% of users have “advanced setups,” (some of which would be better labeled “crazy setups”). As with anything CE Image related, if you run into any problems or need help, please ask! A number of settings have been devised to overcome the aforementioned special server setups. The following extended configuration options are completely optional and rarely needed. Please note that you don’t need all of the settings. You may choose to only copy one or more as needed.

ExpressionEngine® 2.x

Simply copy what you need from the following code and paste it in your system/expressionengine/config/config.php file after the line that reads, // END EE config items.

/*
|--------------------------------
| CE Image Advanced Config Items
|--------------------------------
|
| The following settings are only for advanced setups! You should very
| rarely need to change anything below.
*/

/*
| The ce_image_current_domain item can generally be left blank, and the
| plugin will figure it out.
*/

$config['ce_image_current_domain'] = '';

/*
| The ce_image_unique option can be set to 'filename', 'directory_name',
| or 'none'. See the docs for more details.
*/

$config['ce_image_unique'] = 'filename';

/*
| The ce_img_src_regex takes an associative pair of values
| that you would like to preg_replace (a PHP function) the src path with.
| This occurs before the plugin tries to find the image on the server.
| Ex: array( '^/images/(?!made)' => '/some/server/path/images/');
*/

$config['ce_image_src_regex'] = array();

/*
| The ce_image_made_regex takes an associative pair of values that you
| would like to preg_replace (a PHP function) the made variable with.
| This occurs right before the made variable is returned to the plugin.
| Ex: array( '^/images/' => 'http://www.example.com/images/');
*/

$config['ce_image_made_regex'] = array();

/*
| Can be '' (default), or the name of a folder that you would like to be
| automatically created in the same image directory as the source
| image (if the source image is above web root). The manipulated image
| will then be cached inside this directory. If the image is below web
| root, the folder will be created in the cache_dir instead. If you are
| pulling images from below web root, it is best to leave this as ''
*/

$config['ce_image_auto_cache'] = '';

/*
| By default, CE Image uses the EE installation's root folder as the base
| path for CE Image. All relative paths and references will build off of
| this path's value. This setting allows you to override the default, and
| can also be overridden in the global_array in your index.php file.
*/

$config['ce_image_document_root'] = '/server/path/to/site_document_root/';

/*
| The mode (permission level) to try and set the created image
| to. Must be octal. See http://php.net/manual/en/function.chmod.php for
| more info. Defaults to: 0644
*/

$config['ce_image_image_permissions'] = 0644;

/*
| The mode (permission level) to try and set the created directories to.
| Must be octal. See http://php.net/manual/en/function.chmod.php for
| more info. Defaults to: 0775
*/

$config['ce_image_dir_permissions'] = 0775;

/*
| By default, CE Image will replace spaces with %20 in image URLs. You
| can disable this behavior to leave the spaces unchanged by setting
| this to 'no'.
*/

$config['ce_image_encode_urls'] = 'no';

/*
| Amazon S3 settings and optional headers. For use with the option AWS
| extension. See the installation instructions for more details on how
| to install the extension.
*/

$config['ce_image_aws_key'] = '';
$config['ce_image_aws_secret_key'] = '';
$config['ce_image_bucket'] = '';
$config['ce_image_aws_request_headers'] = array();
$config['ce_image_aws_request_headers']['Cache-Control'] = 'max-age=' . (30 * 24 * 60 * 60);
$config['ce_image_aws_request_headers']['Expires'] = gmdate("D, d M Y H:i:s T", strtotime('+1 month') );
$config['ce_image_aws_storage_class'] = 'STANDARD';
/*
| To use cloudfront with your AWS setup, simply add your cloudfront
| subdomain (in addition to the above AWS info) to the following config
| item. If the cloudfront URL is d38tz0dcx54k85.cloudfront.net, then
| the subdomain would be 'd38tz0dcx54k85'.
*/

$config['ce_image_aws_cloudfront_url'] = '';
/*
| To prevent the AWS S3 or CloudFront domains from being automatically
| appended, you can set the following setting to "n". The default is
| "y". This setting is useful if you have configured custom domains
| for use with AWS, and you don't want to append the default AWS domain.
*/

$config['ce_image_aws_auto_url'] = 'y';
// END CE Image advanced config items

Note: You should always use EE’s native tag caching when using Amazon S3 with your site (please view the performance page for more details).

ExpressionEngine® 1.x

Simply copy what you need from the following code and paste it in your system/config.php file below the other config items, but above the ?>.

$conf['ce_image_current_domain'] = '';
$conf['ce_image_unique'] = 'filename';
$conf['ce_image_src_regex'] = array();
$conf['ce_image_made_regex'] = array();
$conf['ce_image_auto_cache'] = '';
$conf['ce_image_document_root'] = '/server/path/to/document_root/';
$conf['ce_image_image_permissions'] = 0644;
$conf['ce_image_dir_permissions'] = 0775;
$conf['ce_image_aws_key'] = '';
$conf['ce_image_aws_secret_key'] = '';
$conf['ce_image_bucket'] = '';
$conf['ce_image_aws_request_headers'] = array();
$conf['ce_image_aws_request_headers']['Cache-Control'] = 'max-age=' . (30 * 24 * 60 * 60);
$conf['ce_image_aws_request_headers']['Expires'] = gmdate("D, d M Y H:i:s T", strtotime('+1 month') );
$conf['ce_image_aws_storage_class'] = 'STANDARD';

MSM Configuration Overrides

When using Multiple Site Manager (MSM), you may sometimes need site-specific settings. Please note that you don’t need all of the settings. You may choose to only copy one or more as needed.

ExpressionEngine® 2.x

You may override any of the following settings via the global_vars array in the site’s index.php file.

$assign_to_config['global_vars']['ce_image_document_root'] = '/server/path/to/document_root/';
$assign_to_config['global_vars']['ce_image_src_regex'] = array();
$assign_to_config['global_vars']['ce_image_made_regex'] = array();
$assign_to_config['global_vars']['ce_image_encode_urls'] = 'no';
$assign_to_config['global_vars']['ce_image_disable_xss_check'] = 'yes';
$assign_to_config['global_vars']['ce_image_add_dims'] = 'no';

Note: The ExpressionEngine® team has recently broken the ability to use arrays in global variables (they still work as expected for config variables) for EE2.x, and you will now get "Array to string conversion errors" if you try to use them. To get around these errors, instead of using the traditional array syntax:
$assign_to_config['global_vars']['ce_image_made_regex'] = array( '^/' => '/~user/', 'foo' => 'bar' ); You can now use the following modified syntax where array items are separated with a pipe character |, and key => value pairs are separated with =>:
$assign_to_config['global_vars']['ce_image_made_regex'] = '^/=>/~user/|foo=>bar';

ExpressionEngine® 1.x

You may override any of the following settings via the global_vars array in the site’s index.php file.

$global_vars = array(); // This array must be associative
$global_vars['ce_image_document_root'] = '/server/path/to/document_root/';
$global_vars['ce_image_src_regex'] = array();
$global_vars['ce_image_made_regex'] = array();