Skip to content

Instantly share code, notes, and snippets.

@jawngee
Created November 26, 2020 08:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jawngee/36c104f8a8b8ea7e7f6b0f0b837affa5 to your computer and use it in GitHub Desktop.
Save jawngee/36c104f8a8b8ea7e7f6b0f0b837affa5 to your computer and use it in GitHub Desktop.
<?php
// Add this to your theme's functions.php
// This filter will insure that the wp-image-{IMAGEID} class is added to your
// image tags, allowing media cloud to work more optimally
add_filter('wp_get_attachment_image_attributes', function($attrs, $attachment, $size) {
if (!empty($attachment) && isset($attrs['class'])) {
$attrs['class'] .= ' wp-image-'.$attachment->ID;
}
return $attrs;
}, PHP_INT_MAX, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment