Last active
August 29, 2015 14:17
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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