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?


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"]'); ?>

@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


Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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