0

I have an image gallery on a page, and I'm using advance custom fields to pull in a thumbnail and a larger version of that image. Right now, I have it set up as two separate fields so the user has to upload two separate images (a thumbnail and a full size). I'm attempting to set it up so the user only has to upload one image, but when I follow the example on http://www.advancedcustomfields.com/resources/field-types/image/, my thumbnails don't work, but the full image still does. Here's the code I've been working with:

<?php query_posts(array(
                'post_type' => 'gallery_images',
                'posts_per_page' => 20,
)); ?>

<?php while (have_posts()) : the_post(); $gallery_images; 

                $attachment_id = get_field('gallery_full');
                $size = "thumbnail"; // (thumbnail, medium, large, full or custom size)
                $image = wp_get_attachment_image_src( $attachment_id, $size );

?>
      <div class="gallery_image_wrap"><a rel="shadowbox[galpage]" href="<?php the_field('gallery_full'); ?>"><img src="<?php echo $image[0]; ?>" /></a></div>                    


<?php endwhile; ?> 
<?php wp_reset_query(); ?>

And this is an example of what it returns:

<div class="gallery_image_wrap">
<a href="http://example.com/photo.jpg" rel="shadowbox[galpage]">
<img src=" ">
</a>
</div>

What am I doing wrong? (Also, I tried uploading a new image to see if that was a solution, and I still encountered the same issue.)

1 Answers1

0

wp_get_attachment_image_src will return the original image of the thumbnail doesn't exist on the local file system. This function returns a boolean value, TRUE if the thumbnail is being used, FALSE if the original is being used.

You can check via:

<?php while (have_posts()) : the_post(); $gallery_images; 

                $attachment_id = get_field('gallery_full');
                $size = "thumbnail"; // (thumbnail, medium, large, full or custom size)
                $image = wp_get_attachment_image_src( $attachment_id, $size );
                if(!$image[3]) { echo "Thumbnail not available"; }
?>

The above code probably wont do much for your problem, but it will give you a better idea on where the logic is breaking.

If this is in fact what is happening, you should look into PHP's memory limits according to some documentation. This may be resolved via adding the following line to .htaccess:

php_value memory_limit 128M
brasofilo
  • 25,496
  • 15
  • 91
  • 179
David Houde
  • 4,835
  • 1
  • 20
  • 29
  • After doing that, it appears that Wordpress isn't generating the thumbnails. I tried adding the memory limit to the .htaccess file with no luck... Any other suggestions? – Brittany Layne Rapheal Jul 23 '13 at 16:50