Skip to content

Instantly share code, notes, and snippets.

@ellenmva
Last active August 29, 2015 14:17
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 ellenmva/deb03f24f1a0e47ed3dd to your computer and use it in GitHub Desktop.
Save ellenmva/deb03f24f1a0e47ed3dd to your computer and use it in GitHub Desktop.
Filter for elSue Single Bits for DMS that takes image from Dynamic Featured Image plugin and replaces as background for Single Bits container when Featured Image option is selected.
<?php
add_filter('elsue_bits_img_id' , 'sb_dynamic_image');
function sb_dynamic_image($thumb_id) {
global $post;
if( class_exists('Dynamic_Featured_Image') ) {
global $dynamic_featured_image;
// Get all dynmaic images
$featured_images = $dynamic_featured_image->get_featured_images( $post->ID );
// Loop through images
if($featured_images) :
foreach ($featured_images as $key => $image) {
$image_id[] = $image['attachment_id'];
}
$thumb_id = $image_id[0]; // Getting the first image in array with 0, 2nd image is 1, etc.
endif;
}
return $thumb_id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment