Home Forums General Issues Apply Custom Thumbnail Size to Image


Apply Custom Thumbnail Size to Image

  • Hi, I’m using the following code to pull in a image associated with a custom taxonomy. I need to apply a custom thumb size – set in WP function file – to this image, but can’t figure out where the class goes. My custom image size is called “tax-grid500”.

    <img class="img-responsive img-thumbnail" src="<?php the_field('taximage', 'industrygroups_'.$lc->term_id); ?>" />

  • If you need to apply different sizes to an image added with ACF the I’ve found the best choice is to have it return the attachment id rather than any of the other things it can return. Then it is simple to us a different images sizes of the same image.

    $attachment_id = get_field('taximage', 'industrygroups_'.$lc->term_id);
    if ($attachment_id) {
      $image = wp_get_attachment_image_src($attachment_id, 'my-custom-size');
      if ($image) {
        ?><img class="img-responsive img-thumbnail" src="<?php echo $image[0]; ?>" /><?php 
      } // end if image
    } // end if attachment_id
  • *edited* that works, thank you!

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

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