WordPress.org

Support

Support » How-To and Troubleshooting » Need multiple image sizes inside loop

Need multiple image sizes inside loop

  • The loop currently gets the first image in a post..Im not sure if it’s getting the thumbnail size or what, but I can’t change it.

    I use this function inside functions.php:

    function first_image() {
    $files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image');
      if($files) :
        $keys = array_reverse(array_keys($files));
        $j=0;
        $num = $keys[$j];
        $image=wp_get_attachment_image($num, 'large', false);
        $imagepieces = explode('"', $image);
        $imagepath = $imagepieces[1];
        $thumb=wp_get_attachment_thumb_url($num);
        print "<img src='$thumb' class='thumbnail' />";
      endif;
    }

    thumbnail class when changed has no effect:

    .thumbnail{
              width:75;
              height:75;
    
    }

    The loop simply calls:

    <?php first_image(); ?>

    I want to be able to use different widths and heights for the first image depending on various conditions.

  • The topic ‘Need multiple image sizes inside loop’ is closed to new replies.
Skip to toolbar