0

I am using Wordpress Pods CMS and I have a foreach loop to show an unordered list of images. I would like to turn the images into thumbnail size (using the WordPress media thumbnail settings in the dashboard).

My code currently look like this...

<ul>
<?php
foreach ($thePod->get_field('images') as $photo) {
  echo "<li><img src=\"{$photo['guid']}\" alt=\"{$name}\" /></li>";
}
?>
      <?php else:?>
      <p>no photos</p>
      <?php endif;?>
</ul>

I tried putting .... "{$photo['guid'], 'thumbnail'}" but that doesn't work and I know this usually works ... "wp_get_attachment_image_src($image['0']['id'], 'thumbnail');" when I want to display one image only.

tshepang
  • 12,111
  • 21
  • 91
  • 136
kayee
  • 330
  • 2
  • 6
  • 21

1 Answers1

3

try this:

foreach ($thePod->get_field('images') as $photo) {
  $thumbnail = wp_get_attachment_image_src( $photo[ID], 'thumbnail' );
  echo "<li><img src='$thumbnail[0]' alt='$name' /></li>";
}

mkm

manishie
  • 5,302
  • 1
  • 20
  • 21
  • thanks @manishie for your reply. How would I apply that to my current code? I see this person has it inside his image tag.. http://wordpress.org/support/topic/slideshowpro-038-wordpress.. is it similar to this? and also what if I have other image format too like png or image extension is jpeg as well as jpg. – kayee Oct 15 '12 at 05:37
  • Sandy, rather than the quick hack I gave you before, I've revised my answer to figure out what you may have been doing incorrectly in your code. Please see if it works for you... – manishie Oct 15 '12 at 06:13
  • You'll want to use $thePod->field( 'images' ) instead http://pods.io/docs/code/pods/field/ – Scott Kingsley Clark Jun 10 '14 at 14:45