Skip to content

Instantly share code, notes, and snippets.

@darinronne
Last active July 7, 2020 22:35
Show Gist options
  • Save darinronne/b97b17165546eb9854dd735831ba5bc3 to your computer and use it in GitHub Desktop.
Save darinronne/b97b17165546eb9854dd735831ba5bc3 to your computer and use it in GitHub Desktop.
WP Engine HTML Post-Processing Rule - wp_get_attachment_image_src()

The WP Engine CDN doesn't apply to images that are output via wp_get_attachment_image_src().

<?php echo esc_url( wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' )[0] ); ?>

You can add a HTML Post-Processing rule that will get them. (Found in the site's WP admin: WP Engine > General Settings)

Replace SITE_URL and UNIQUE_CDN_STRING.

#https?://www\.SITE_URL\.com/wp-content/uploads# => https://UNIQUE_CDN_STRING-wpengine.netdna-ssl.com/wp-content/uploads
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment