0

I am building a custom WordPress theme.

I am using Advanced Custom Fields to have an area for the user to upload custom images.

This is what I have in my functions.php file. My images aren't taking up the full designated space, instead they are being cropped by their ratio.

function custom_theme_setup() {
    add_theme_support( 'post-thumbnails' ); 
    add_image_size( 'blog', 810, 400, true );
    add_image_size( 'home-right-column-block', 305, 300, true); 
  }
  add_action( 'after_setup_theme', 'custom_theme_setup' );

Each time I test something, I ensure I upload a fresh new image and the image I upload is way larger than the dimensions I've specified so it should work.

1

1 Answer 1

1

I figured it out. I had to pass the image in as an ID rather than a URL.

<?php
    $image_id = get_field('content_image_1');
    $image_size = 'home-left-column-block';
    $image_array = wp_get_attachment_image_src($image_id, $image_size);
    $image_url = $image_array[0];
 ?>
 <img src="<?php echo $image_url; ?>" alt="<?php echo the_field('content_block_title_1'); ?>" height="420" width="630">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.