Home Forums Add-ons Repeater Field Repeater Image Thumbnail Size


Repeater Image Thumbnail Size

  • Hello. I’m using a repeater field and a calling a background image. It’s all working but it’s pulling the full width size of the image and I only want it to pull the custom thumbnail size I have setup in wordpress called “blog-featured.” How do I do that? Here is what I have:

     <?php if( get_field('featured') ): ?>
       <?php while( has_sub_field('featured') ): 
        $image = get_sub_field('image');
          <li class="post">
    			<div class="headline">
                <a class="img-bkgd" target="_blank" href="<?php the_sub_field('link'); ?>">
    			 <div class="img-bkgd-image" style="background-image: url('<?php echo $image['url'];?>');"></div>
                <div class="img-bkgd-text">
                  <p class="name"><?php the_sub_field('name'); ?></p>
                  <p class="separator">&mdash;</p>
                  <p class="date-location"><?php the_sub_field('date_and_location'); ?></p>
              <div class="description">
                <p><?php the_sub_field('description'); ?></p>
              <a class="button small float-right" target="_blank" href="<?php the_sub_field('link'); ?>">read more <span class="next">&rsaquo;</span></a>
              <br class="clear" />
    		</li><?php endwhile; ?><?php endif; ?>
  • @gravycreative: Rather than using $image['url'] you just need to use $image['sizes']['blog-featured']

    That should fix it.

  • Perfect, that worked, thanks! I couldn’t find that in the documentation.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Repeater Image Thumbnail Size’ is closed to new replies.