wp_get_attachment_image_src returning full size images

In functions.php, I have:

add_image_size( 'coach-profile-pic', 88, 113, true);

In my template, I have:

Read More
$pic = wp_get_attachment_image_src( $picture['profile_pic'][0], 'coach-profile-pic' );

For some images, they’re being returned in full size while others are being returned as 88×113 (as expected). All of the images were uploaded after the custom image size was added to functions.php For the images that are being returned as full size, I’ve checked and the 88×113 size of that image exists on the server. I can’t figure out why full size images are being returned rather than the custom image size. Thanks in advance!

Related posts

Leave a Reply

1 comment

  1. I believe the problem is that some of the pictures do NOT have proper sizes to return. You have to check if you generate proper size photos when you add them to db.

    Normally when I import files into wp I do something like:

    require_once( ABSPATH . 'wp-admin/includes/image.php' );
    $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
    wp_update_attachment_metadata( $attach_id, $attach_data );
    

    Of course it’s only sample, and you have to adapt it into your script and generate proper size of image. Good luck!