Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

up vote 0 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
add comment

@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

share|improve this answer
add comment

Your Answer

 
discard

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.