0

I want to display all the images added as gallery in a post with prettyphoto class.

I am using this code.

    <?php
        /* The loop */
        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 )
                {
                    ?>

                 <a href="<?php echo $src; ?>" rel="prettyPhoto[pp_gal]"><img src="<?php echo $src; ?>"  alt="Gallery image"  /></a>

                <?php
                }
            endif;
            endwhile;
    ?>

Its is displaying the photos but it is showing only thumbnail as src. I want to display Full Image.

How can i display full image instead of thumbnail ?

1
  • work on your acceptance rate, if somebody gives you an answer which helps you to resolve your issue, then mark it as correct Oct 15, 2013 at 11:32

4 Answers 4

1

You can alter the foreach loop as follows,

 foreach( $gallery['ids'] as $attachment_id )
 {
       $image_attributes = wp_get_attachment_image_src( $attachment_id );
       if( $image_attributes ) {

           $src = isset($image_attributes[0])? $image_attributes[0] : '';

            if(!empty($src)) {
                ?>

             <a href="<?php echo $src; ?>" rel="prettyPhoto[pp_gal]"><img src="<?php echo $src; ?>"  alt="Gallery image"  /></a>

            <?php
            }
       }
  }

You can specify required dimension, as second parameter for , 'wp_get_attachment_image_src()' function.

0

TutsPlus did a pretty straightforward article on exactly this a while back. Perhaps you could give it a read and let us know if you run into any problems? This forum is good with problems. The basis of your question is more of a "point me at a tutorial" issue though. Done and done :)

You may need to refer to a code snip like this to get gallery integration though, once you've done the basics.

0

Try this

// Query the custom post type to display
$args = array('post_type' => 'CUSTOM POST TYPE');
$query = new WP_Query( $args );

if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
   // your gallery loop
endwhile; endif;
1
  • Please add an explanation to your answer: why could that solve the problem?
    – fuxia
    Oct 15, 2013 at 11:47
0

Read the documentation for get_post_gallery and you'll see that the function is intended to return thumbnail image sources. The function also returns a string IDs of images. So you can split it into array, and run wp_get_attachment_link within the same loop (with a defined index to reference correct image file ID) to query for full image source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.