6

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?

Thanks

2 Answers 2

2

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

@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 ) { 
    var_dump($gallery);
}

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

http://www.siteurl.com/wp-content/uploads/2013/10/eiffel-tower.jpg

rather than

http://www.siteurl.com/wp-content/uploads/2013/10/eiffel-tower-150x150.jpg

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.