Skip to content

Instantly share code, notes, and snippets.

@mathetos
Last active August 29, 2015 14:05
Show Gist options
  • Save mathetos/d32dcbd4bfa5d4e6c796 to your computer and use it in GitHub Desktop.
Save mathetos/d32dcbd4bfa5d4e6c796 to your computer and use it in GitHub Desktop.
Change image class if meta field available
<?php
add_filter('get_image_tag_class', 'add_imagelens_frames', 0, 4);
function add_imagelens_frames($classes, $id) {
$singlelens = get_post_meta( $id, '_enable_lens', true );
if ($singlelens === 'imagelens-single') {
return $classes . ' ' . $singlelens;
} else {
return $classes;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment