Dynamic Featured Image

I have recently installed Dynamic Featured Image plugin for wordpress. But I do not know how to link images. I’m trying to create me a gallery like this http://www.subcreative.com.au/#work – Scroll down to the projects and you will see .

I have put this code in functions.php

Read More
<?php
 while ( have_posts() ) : the_post();

   if( function_exists('dfi_get_featured_images') ) {
       $featuredImages = dfi_get_featured_images();

       //Now, loop through the image to display
   }

   endwhile;
?>

and used this to link the image.

echo ' <a class="fancybox" href="'. dfi_get_featured_images() .'" style="text-align:center">Take a look</a> '; ?>

But when I try to open the image, it becomes “/array”

Related posts

Leave a Reply

3 comments

  1. Im not a wordpress dev but I’ve seen this on the wordpress website that I tried to fix.
    so maybe you can try this one.

    if( class_exists('Dynamic_Featured_Image') ):
        global $dynamic_featured_image;
        global $post;
         $featured_images = $dynamic_featured_image->get_featured_images( $post->ID );
    
         if ( $featured_images ):
            ?>
                <?php foreach( $featured_images as $images ): ?>
                   <img src="<?php echo $images['full'] ?>" alt="">
                <?php endforeach; ?>
            <?php
            endif;
    endif;
    

    this works in my case. I’m using DFI 3.1.13

  2. This answer is only valid for plugin version 2.0.2 and below.

    You need to loop throught the returned array and display the image manually. Try this:

    <?php   
    
        if( function_exists('dfi_get_featured_images') ) {
           $featuredImages = dfi_get_featured_images();
    
           //Loop through the image to display your image
    
           if( !is_null($featuredImages) ){
    
                $links = array();
    
                foreach($featuredImages as $images){
                    $thumb = $images['thumb'];
                    $fullImage = $images['full'];
    
                    $links[] = "<a href='{$fullImage}' class='dfiImageLink'><img src='{$thumb}' /></a>";
                }
    
                echo "<div class='dfiImages'>";
                foreach($links as $link){
                  echo $link;
                }                
                echo "</div>";
             }        
        }
    
    ?>
    
  3. try this inside of have posts loop

    $img=dfi_get_featured_images();
    $url=$img['full'];
    echo ' <a class="fancybox" href="'. $full .'" style="text-align:center">Take a look</a> ';
    

    If full doesn’t work try thumb also.