Abhi
Abhi

Reputation: 299

get full wordpress gallery image

i have an image slider in the page i wanted to place images by single post,wordpress provide get_post_gallery function to get images by single post,this phase is done but the
problem is that it show thumbnail images i want to show full image on the slider, like we do in featured image scenario. $img = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'tasty-thumb'); here is my code inside the template:

 <?php
              query_posts('category_name=tandem-slider');
              while ( have_posts() ) : the_post();
                if ( get_post_gallery() ) :
                    $gallery = get_post_gallery( get_the_ID(), false );

                    /* Loop through all the image and output them one by one */
                    foreach( $gallery['src'] AS $src )
                    {
                        ?>
                         <div class="jump_slider_single">
                             <img src="<?php echo $src; ?>" alt="" class="img-responsive">
                             <article>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                             tempor incididunt.</article>
                             <span class="double_shad"></span>
                        </div><!--jump_slider_single-->                 
                        <?php
                    }
                endif;
            endwhile;
        ?>

i want to get image according to the image size given by me in function.php

 if ( function_exists( 'add_image_size' ) ) { 

add_image_size( 'gallery-image', 1350, 500, true ); }

how i do this i got confused

Upvotes: 0

Views: 1204

Answers (1)

Khushboo
Khushboo

Reputation: 1817

Try this :-

$gallery = get_post_gallery( get_the_ID(), false );

$ids = explode( ",", $gallery['ids'] );

foreach( $ids as $id ) {

   $link   = wp_get_attachment_url( $id );

   $image_list . = '<li>' . $link . '</li>';

} 

Upvotes: 0

Related Questions