• Resolved squizeers

    (@squizeers)


    I am using the following code to loop through the galley images in the post

    <?php
    $galleries = get_post_galleries_images( $post );
    foreach( $galleries as $gallery ) {
     // Loop through each image in each gallery
     foreach( $gallery as $image ) {
      $image_list .= '<a href="'.'LINK TO LARGE IMAGE'.'"><img src="'. $image .'"/></a>';
     }
    }
    echo $content .= $image_list;
    ?>

    How do I get the link to large image of the gallery image so that I can replace “LINK TO LARGE IMAGE” in the above code with it?

    Any help is be much appreciated

Viewing 1 replies (of 1 total)
  • Thread Starter squizeers

    (@squizeers)

    Solved the issue by using the function at:

    https://philipnewcomer.net/2012/11/get-the-attachment-id-from-an-image-url-in-wordpress/

    now my code looks like:

    <?php
    $galleries = get_post_galleries_images( $post );
                foreach( $galleries as $gallery ) {
                    foreach( $gallery as $image ) {	
    
    					echo $imageID = get_attachment_id_from_url( $attachment_url = $image );
    					$largeImage = wp_get_attachment_image_src( $imageID,large );
    
                       $image_list .= '
    				   <div class="col-xs-4 col-sm-4">
    				   <a class="fancybox'.$post->ID.'" rel="fancybox'.$post->ID.'" href="'.$largeImage[0].'"><img src="'. $image .'"/></a>
    				   </div>';
                    }
                }
            echo $image_list;
            ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Get the large image of the gallery image’ is closed to new replies.