Support

Account

Home Forums General Issues Custom Image Sizes Reply To: Custom Image Sizes

  • “custom-size” needs to be defined in the functions.php file of your theme. It will look something like this…

    /**
     * Add automatic image sizes
     */
    if ( function_exists( 'add_image_size' ) ) { 
    	add_image_size( 'post-feature-img', 770, 120, true ); //(cropped)
    	add_image_size( 'member-img', 200, 200, false ); //(scaled)
    	add_image_size( 'people-img', 360, 360, true ); //(cropped)
    	add_image_size( 'people-featured-img', 150, 120, true ); //(cropped)
    }

    If you’ve already uploaded images to your library you’ll need to re-process them with something like Ajax Thumbnail Rebuild…
    http://wordpress.org/plugins/ajax-thumbnail-rebuild/

    Now I create a field called “Bio Image” with a name of “bio-image” and set it to return the Image ID of the uploaded file.

    After the images have been resized by WordPress and I create my field I can add code to my theme.

    Assuming this is in a loop that returns a list of bios and I want each of them to have an image of an employee, this is what I’d use…

    <div class="bio-image">
      <?php
        $attachment_id = get_field('bio_image');
        $size = "people-img"; // (thumbnail, medium, large, full or custom size)
        $image = wp_get_attachment_image_src( $attachment_id, $size );
        // url = $image[0];
        // width = $image[1];
        // height = $image[2];
      ?>
      <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark">
        <img class="people-image" alt="Image of <?php the_title(); ?>" src="<?php echo $image[0]; ?>" />
      </a>
    </div>

    In the above code I’m using my custom “people-img” image size that we defined in the functions.php file.

    Unfortunately, if this doesn’t help we’ll need to see a screen cap of your current fields rules as well as the exact code you’re trying to implement.