WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following code on my site.

<?php // image gallery content 
if( has_shortcode( $post->post_content, 'gallery' ) ) {                     
    $gallery = get_post_gallery_images( $post->ID );

    $image_list = '<ul id="cfImageGallery">';                       
    foreach( $gallery as $image ) {// Loop through each image in each gallery
        $image_list .= '<li><img src=" ' . str_replace('-150x150','',$image) . ' " /></li>';
    $image_list .= '</ul>';                     
    echo $image_list;                       

My problem is that get_post_gallery_images returns thumbs files instead of fill size so Im using the str_replace function to solve it.

How can I make to retrieve the full size urls?


share|improve this question
up vote 1 down vote accepted

If you're working within a template file, this code should work. However, I didn't test it.

<?php echo do_shortcode('[gallery size="full"]'); ?>
share|improve this answer

@tfer77 has given the right answer. I am here explaining it in a more better way.

You need to add size="full" attribute to the gallery shortcode in the post content like

[gallery ids="836,830,829" size="full"]

Now when you use

$gallery = get_post_gallery_images( $post->ID );

You will get full size images. You can check the same by using the filter get_post_gallery

Paste the below code in your theme's functions.php file.

add_filter( 'get_post_gallery', 'wpse_get_full_size_gallery_images', 10, 3 );
function wpse_get_full_size_gallery_images( $gallery, $post, $galleries ) { 

and the page where you have used get_post_gallery_images, you will get a image url as


rather than


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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