WordPress.org

Ready to get started?Download WordPress

Forums

Dynamic Featured Image
[resolved] Please explain version 3.0 (2 posts)

  1. jenna_d
    Member
    Posted 4 months ago #

    Since upgrading to version 3, dynamic featured image no longer works on my theme. I have updated the retrieval code to:

    if( class_exists('Dynamic_Featured_Image') ) {
    global $dynamic_featured_image;
    $featured_images = $dynamic_featured_image->get_featured_images( $postId );

    //You can now loop through the image to display them as required
    }

    BUT there are no instructions as to how to call this data as an image. Please can you give an example of how you can call a linked image within a theme...

    https://wordpress.org/plugins/dynamic-featured-image/

  2. Ankit Pokhrel
    Member
    Plugin Author

    Posted 4 months ago #

    Hello Jenna,

    The process for calling the data as an image is same as before. Try this:

    if( class_exists('Dynamic_Featured_Image') ) {
      global $dynamic_featured_image;
      $featuredImages = $dynamic_featured_image->get_featured_images( $postId );
    
      //You can now loop through the image to display them as required
      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}' alt='' height='{$height}' width='{$width}' /></a>";
            }
    
            echo "<div class='dfiImages'>";
            foreach($links as $link){
              echo $link;
            }
            echo "<div style='clear:both'></div>";
            echo "</div>";
         }
    }

    Thanks,
    Ankit

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.