WordPress.org

Ready to get started?Download WordPress

Forums

Need multiple image sizes inside loop (1 post)

  1. denutza
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic