Customizing ExactDN

While ExactDN is designed to be pretty much automatic, it has a ton of filters and constants that will allow developers to customize it's behavior. If you're familiar with Jetpack's Photon module, you'll see pretty much all the same filters, and likely a few extras. Uppercase items are constants that should be defined in wp-config.php, lowercase items are filters that can be run elsewhere, like your functions.php. I'll try to flesh these out more in the coming weeks, but here's the list for now (they are fully documented in the class-exactdn.php file):

EXACTDN_EXCLUDE - By default, ExactDN rewrites urls for all external resources: JS, CSS, fonts, etc. This allows you to specify patterns to ignore for non-image resources by defining this constant in your wp-config.php. It does not affect images, as there are other ways to go about that (below). Valid values include a simple string, or an array of string pattern matches. Wildcards (*) are implied, so do not include them or you will get unexpected results. See examples.

EXACTDN_PREVENT_SRCSET_FILL - ExactDN will attempt to make all images "responsive" for mobile and hi-dpi/retina devices. Define this constant in your wp-config.php if the "srcset fill" is causing issues on your site.

EXACTDN_IMAGE_DOWNSIZE_SCALE - When explicit dimensions are given to the image_downsize() function, ExactDN will crop an image to those exact dimensions. If you prefer to have scaling be the default for such operations, define this to true in your wp-config.php.

exactdn_content_width - Many themes define a global $content_width variable (in pixels), which ExactDN will use to constrain images found in page/post content, use this filter to override that global setting.

exactdn_skip_image - Defaults to false, second parameter is usually the image url, third depends on whether it comes from the content filter, or the srcset filter.

exactdn_post_image_args - Filter the array of ExactDN arguments added to an image, which by default, only includes width and height values.

exactdn_admin_allow_image_downsize - While themes and plugins generally use the image_downsize() function, the WP admin also uses it liberally, but ExactDN is turned off in the WP admin by default (false).

exactdn_override_image_downsize - Provide plugins a way of preventing ExactDN from being applied to images retrieved from WordPress Core. By returning true, the image_downsize filter will terminate immediately.

exactdn_image_downsize_string - Filter the ExactDN arguments added to an image when that image size is a string. For example, when $size is 'full', 'medium', etc.

exactdn_image_downsize_array - Filter the ExactDN arguments added to an image, when the image size is an array of height and width values.

exactdn_admin_allow_image_srcset - Provide plugins a way of running ExactDN for the srcset attribute of images in the WordPress Dashboard (wp-admin).

exactdn_srcset_multipliers - Filter the multipliers ExactDN uses to create new srcset items. Return false to short-circuit and bypass auto-generation.

exactdn_reject_https - Tells ExactDN to ignore/reject images that are served via HTTPS. Defaults to false, set to true to only rewrite non-encrypted image communication.

exactdn_validate_image_url - Overwrite the results of the previous validation steps an image goes through to be considered valid for ExactDN.

exactdn_development_mode - Disables ExactDN URL processing for local development. Defaults to false.

exactdn_skip_for_url - Allow specific image URls to avoid going through ExactDN (in case exactdn_skip_image didn't work for you).

exactdn_pre_image_url - Filter the original image URL before it goes through ExactDN.

exactdn_pre_args - Filter the ExactDN image parameters before they are applied to an image.

Still need help? Contact Us Contact Us