Support » Developing with WordPress » Thumbnails with custom size

  • Resolved Alexandre Tavares


    I’m trying to use thumbnails with custom size.

    I placed add_theme_support( ‘post-thumbnails’ ) in functions.php to start the wordpress thumbnail suport for the theme.

    After I placed some custom sizes:

    add_image_size( ‘post-single-img-size’, 785, 350, true );
    add_image_size( ‘post-1-large-img-size’, 592, 350, true );
    add_image_size( ‘post-1-small-img-size’, 296, 175, true );

    When I uploaded an image and I call the_post_thumbnail(‘post-1-large-img-size’); in the index.php, I see the image with disproportionate size.

    Whit the HTML code like this

    <img width="1920" height="1080" src="" alt="" />

    The src points to the original image.

Viewing 13 replies - 1 through 13 (of 13 total)
  • if you create custom size after your image being uploaded, it may not generate the custom image yet. you will need to regenerate the image. you can use image generator plugin like this one :

    Alexandre Tavares


    I uploaded a new image.

    how about trying to upload jpg instead bmp?

    Alexandre Tavares


    Yes. The problem continues.

    <img width="1920" height="1080" src="" alt="">

    Do you see class attr and srcset attr in the img tag?
    If not, you might have changed the output of the_post_thumbnail with filter hook or some sort.
    If yes, I would check if there is a syntax error in functions.php before/after the add_image_size.

    BTW, what if you call the_post_thumbnail(); without args?
    Does it show thumbnail image?

    What is the actual size of image that is uploaded by you?

    ikaring is right. the result seem weird. your image tag don’t have any class. some code may overwrite how the_post_thumbnail work.

    Definitely any plugin is overriding your code. Try deactivating all plugins. If that resolves the issue, reactivate each one individually until you find the cause.

    Alexandre Tavares


    I’m sorry. I thought that class is not important information. The complete output is

    <img width="2048" height="1049" src="" class="attachment-post-1-large-img-size size-post-1-large-img-size wp-post-image" alt="" />

    If I call the function without argument. I have the same result.

    If a use functions.php with just add_theme_support( ‘post-thumbnails’ ); nothing more, and I call the_post_thumbnail(); I have the same result.

    If I call the_post_thumbnail(‘medium’); I have the output:

    <img width="300" height="225" src="" class="attachment-medium size-medium wp-post-image" alt="Alternativo" />

    I don’t know the default value for medium size, but I believe that is 300×225. The problem is src continues pointing to the original image.

    I’m uploading image with different sizes:


    And others

    I don’t have any plugin activated.

    It seems images are not generated.
    Is there a thumbnail image ?

    Please check that your hosting provider has the GD Image Library extension installed and enabled.

    Alexandre Tavares


    It worked!!! I installed the GD Image Library and everything is working now. Thank you all!

    Glad 🙂 to know this.

    Yeeey, congrats!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Thumbnails with custom size’ is closed to new replies.