I'm using get_post_gallery_images and it's spitting images out as 150x150. It doesn't look like it takes a size parameter, so I assumed it would just spit out the largest image or preferably one of my defined sizes. 150x150 is too small though, is there somewhere I can declare what size gallery images I want?

For instance I'm doing:

$gallery = get_post_gallery_images( $post ); 
foreach ($gallery as $img) { ?>
    <li><img src="<?php echo $img; ?>" /></li>
<?php } ?>

All of these images are coming out as 150x150, is there something I'm missing?


If you want get_post_gallery_images to give you full size images, you can use the following:

// Use full size gallery images for the next gallery shortcode: 
add_filter( 'shortcode_atts_gallery', 'wpse_141896_shortcode_atts_gallery' );
// Your code:
$gallery = get_post_gallery_images( $post ); 
foreach ($gallery as $img) { ?>
    <li><img src="<?php echo $img; ?>" /></li>
<?php } 


 * Set the size attribute to 'full' in the next gallery shortcode.
function wpse_141896_shortcode_atts_gallery( $out )
    remove_filter( current_filter(), __FUNCTION__ );
    $out['size'] = 'full';
    return $out;

In this example we remove the filter after using it once, so it will not affect your other galleries.

This way you don't have to include the size="full" attribute in your gallery shortcodes,

  • Thanks, I came across this after some google'n and used it :) it worked nicely. – UzumakiDev Apr 21 '14 at 12:59

Check: https://codex.wordpress.org/Function_Reference/add_image_size WordPress will create a copy with desired size, and then you just display it.

  • Please explain how this is relavent to the question – Pieter Goosen Apr 21 '14 at 7:08
  • @PieterGoosen Read last sentence in the question, you know what function is doing I do not have to explain you that. And there is an code example in a link that I have posted. – user2367837 Apr 21 '14 at 11:41

If you're working within a template file, this code should work.

<?php echo do_shortcode('[gallery size="full"]'); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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