I'm iterating over a custom post type that uses an image from the media library for each item. The images are being rendered for each one correctly with the right size, but for some reason it is loading the full image instead of the medium, which is greatly affecting my page load time.

Here is what I have:

      $args = array( 'post_type' => 'recent-project', 'posts_per_page' => -1 );
      $projects = new WP_Query( $args );
            while ( $projects->have_posts() ) : $projects->the_post();

                echo '<a href="' . $get_permalink(); . '">';
                echo '<div class="item">';
                echo wp_get_attachment_image( get_post_thumbnail_id( $post->ID ), 'medium' );
                echo '</div></a>';


Anyone know how I can get the medium size to load instead of the full?


Check that medium size of that image is generated or not.

if image is not generated then original image size must be lower then medium size image height width.

If the image size is bigger then you can regenerate thumbnail again. hope it will help.


Have you changed any of your thumbnail dimensions after previously uploading images, if so then you would need to regenerate your thumbnails. There is a free plugin for that https://wordpress.org/plugins/regenerate-thumbnails/ Hope this helps :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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