• Resolved Vrunda Pandya

    (@vrunda-pandya)


    Hi,
    I add below code to change thumbnai size + to add custom image size but it’s not work i also use it previously in many templates but in my new template it’s not work i can’t find the mistake, i add this code in functions.php, can anyone help me ???

    if ( function_exists( ‘add_theme_support’ ) ) {
    add_theme_support(‘post-thumbnails’);
    set_post_thumbnail_size(125, 75); // default Post Thumbnail
    add_image_size(‘detail_page_image’,570, 400, false);//(cropped)
    add_image_size(‘listing_img’,125, 85, false);//(cropped)
    }

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Have you altered the image size argument in the functions in your theme template files that show a post thumbnail?

    the_post_thumbnail();
    the_post_thumbnail('detail_page_image');
    the_post_thumbnail('listing_img');

    https://codex.www.ads-software.com/Function_Reference/add_image_size

    Thread Starter Vrunda Pandya

    (@vrunda-pandya)

    thanks you keesiemeijer

    No i don’t alter any arguments in template file, i just write the code as i mention above. please help me to solve it.

    Moderator keesiemeijer

    (@keesiemeijer)

    What theme are you using? And where do you want these new image sizes to appear (categories, single posts, pages …)

    Thread Starter Vrunda Pandya

    (@vrunda-pandya)

    i want new image size for single page and category page and it’s custom taxonomy not for posts and pages , but image size is not added even for posts too. and i am creating my own theme not using any built in template.

    in which cases add_image_size() will not work…..

    Moderator keesiemeijer

    (@keesiemeijer)

    i want new image size for single page and category page and it’s custom taxonomy

    Did you change the_post_thumbnail to the new size in single.php,category.php and taxonomy.php.

    To change the default post thumbnail size, you’ll have to change this (depending on your theme):

    <?php  the_post_thumbnail(); ?>

    To this

    <?php  the_post_thumbnail('detail_page_image'); ?>

    but image size is not added even for posts too

    Do you see the post thumbnails on the front end but not in the right size after altering your theme template files?
    Try to regenarate your post thumbnails with a plugin: https://www.ads-software.com/extend/plugins/regenerate-thumbnails/
    Only do this after a full backup of your database and images.
    https://codex.www.ads-software.com/WordPress_Backups

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘add_image_size() not working’ is closed to new replies.