I want to show thumbnail with custom size.So, I mean scale the thumbnails to avoid load heavy size to browser.I couldnt do it.

Here is my code in my plugin:

<img class="img-responsive img-whp" style="width: 368px;" src="<?php the_post_thumbnail_url(array(450, 450, true)); ?>" alt="1.jpg">

here is the thumbnail size in my theme function.php:

// Add Thumbnail Theme Support
add_image_size( ‘team-slider-thumbnail’, 450, 450, true);

Old Question:

I have below code to show thumbnail on archive page:

                        if ( $thumbnail_id = get_post_thumbnail_id() ) {
                            if ( $image_src = wp_get_attachment_image_src( $thumbnail_id, 'normal-bg' ) )
                                <div class="col-md-12 ulockd-mrgn1210">
                                <div class="ulockd-project-sm-thumb">
                                <img class="img-responsive img-whp" src="<?php printf( '%s', esc_url($image_src[0]) ); ?>" alt="">

there is no normal-bgsize in function.php but the thumbnai image size is: 90x100

also there is no 90x100in wp admin panel.here is admin panel size:

Image sizes
The sizes listed below determine the maximum dimensions in pixels to use when adding an image to the Media Library.

Thumbnail size  Thumbnail sizeWidth 

  Crop thumbnail to exact dimensions (normally thumbnails are proportional)
Medium size Medium sizeMax Width 

Max Height 
Large size  Large sizeMax Width 

Max Height 

When I changed the normal-bg to recognized size in function.php, for example, to custom-size, it doesnt change.

here is my code in function.php:

if (function_exists('add_theme_support'))
    add_theme_support( 'custom-logo' );

    // Add Menu Support

    // Add Thumbnail Theme Support
    add_image_size('large', 700, '', true); // Large Thumbnail
    add_image_size('medium', 250, '', true); // Medium Thumbnail
    add_image_size('small', 120, '', true); // Small Thumbnail
    add_image_size('custom-size', 700, 200, true); // Custom Thumbnail Size call using the_post_thumbnail('custom-size');

so, how can I change the thumbnail size to what I want, for example, to custom-size or medium ?

  • How big is the original file? If the original image is 90x100, that's all you'll get. WordPress can only shrink and crop images. It does not create larger sizes if the original is small. – Jacob Peattie May 20 at 12:40
  • @JacobPeattie I editted question.The images are large enough. – Faruk rıza May 27 at 13:52

Your Answer

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

Browse other questions tagged or ask your own question.