• I think I may have posted in error on another thread, so I am reposting my question as a new topic -I hope this is allowed!

    Hi — I really like the theme and am using it here – https://www.romantichistoricalreviews.com.

    Can you tell me how I can resize the featured images so that the whole of the featured image is shown as a thumbnail (150×225) on the home page? Some of the covers were showing that way and some were not, and I couldn’t work out why they didn’t all work the same way, so I tried the Regenerate Thumbnail plugin – and unfortunately, it resized them all so that only part of the image shows (which is what you can see on the home page now.

    • This topic was modified 6 years, 10 months ago by caz963.

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Theme Author Toshihiro Kanai

    (@mirucon)

    Hi there – Thanks for using the Coldbox theme!

    That is how the theme normally works, it expects images to be 500x250px. Therefore if you’d like to show the whole of the thumbnail for all the images, it will require some kind of customization.

    So can you please try this code on your child theme (which you can download it from here) or somewhere (but not recommended writing on the Coldbox theme), this will use full images of any thumbnail.

    
    function cd_middle_thumbnail_template() {
    
        if ( has_post_thumbnail() ) {
            $thumbnail = get_the_post_thumbnail( get_the_ID(), 'full' );
        } elseif ( cd_index_placefolder_image() ) {
            $thumbnail = '<img src="' . esc_url( get_theme_file_uri( 'img/thumb-medium.png' ) ) . '" alt="noimage" height="250" width="500">';
        } else {
            return;
        }
        echo wp_kses_post( apply_filters( 'cd_middle_thumbnail_template', $thumbnail ) );
    }
    

    I hope this works fine. If you need further help, just let me know!

    Thread Starter caz963

    (@caz963)

    Thanks so much! This has worked in that the display shows the full size covers but ideally, I would like to show 150×225 thumbnails. Is there a way of setting this size?

    Theme Author Toshihiro Kanai

    (@mirucon)

    So this should work in that way. You will need to run the Regenerate Thumbnail plugin to resize all the featured images!

    
    function cd_middle_thumbnail_template() {
    
        if ( has_post_thumbnail() ) {
            $thumbnail = get_the_post_thumbnail( get_the_ID(), '150x225' );
        } elseif ( cd_index_placefolder_image() ) {
            $thumbnail = '<img src="' . esc_url( get_theme_file_uri( 'img/thumb-medium.png' ) ) . '" alt="noimage" height="250" width="500">';
        } else {
            return;
        }
        echo wp_kses_post( apply_filters( 'cd_middle_thumbnail_template', $thumbnail ) );
    }
    
    function create_new_thumbnail_size() {
        add_image_size( '150x225', '150', '225' );
    }
    add_action( 'after_setup_theme', 'create_new_thumbnail_size' );
    
    Thread Starter caz963

    (@caz963)

    Ah, right.

    I suspect that I may have been using the wrong terminology or asking you for the wrong thing, for which I apologise.

    What I want to see on the homepage is a 150×250 (or approx) image of the whole book cover – not just a section of it. Is that possible? I’m sorry if my previous questions have been unclear, but I’m fairly new to this ??

    Theme Author Toshihiro Kanai

    (@mirucon)

    I think the code above will make all the thumbnail images to be 150x250px, I’m not sure what you mean by “just a section of it”? If you could share a screenshot of what you see with the code it would be appreciated. It might not be working as I think.

    Thread Starter caz963

    (@caz963)

    The thumbnails on the homepage – https://www.romantichistoricalreviews.com – are that size.

    Sorry to be a pain on this – but if you go to the homepage and then scroll down to the review called “The English Wife” – you can see what I would like to see – you can see the entire cover of the book at a smaller size.

    Does that make sense? I’m sorry if I’m not explaining myself correctly. Would it be easier if I were to email you a couple of screenshots?

    Thank you for being so patient with me!

    Theme Author Toshihiro Kanai

    (@mirucon)

    Did you run the Regenerate Thumbnails plugin after adding the code?
    I can still see the images whose size is 300×250 which is the default of the theme.

    Thread Starter caz963

    (@caz963)

    Yes, I did run it, and it left all the thumbnails as you see them (apart from the one I changed so you could see it).

    I am running the child theme, and added the code you gave upthread to the function file, so it looks like this:

    <?php
    add_action( ‘wp_enqueue_scripts’, ‘coldbox_enqueue_styles’ );
    function coldbox_enqueue_styles() {
    wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri() . ‘/style.css’ );

    }

    /* ————————————————————————- *
    * Start customizing from here* ————————————————————————– */function cd_middle_thumbnail_template() {

    function cd_middle_thumbnail_template() {

    if ( has_post_thumbnail() ) {
    $thumbnail = get_the_post_thumbnail( get_the_ID(), ‘150×225’ );
    } elseif ( cd_index_placefolder_image() ) {
    $thumbnail = ‘noimage‘;
    } else {
    return;
    }
    echo wp_kses_post( apply_filters( ‘cd_middle_thumbnail_template’, $thumbnail ) );
    }

    function create_new_thumbnail_size() {
    add_image_size( ‘150×225’, ‘150’, ‘225’ );
    }
    add_action( ‘after_setup_theme’, ‘create_new_thumbnail_size’ );

    It’s entirely possible I’ve done something wrong, so please let me know!

    Theme Author Toshihiro Kanai

    (@mirucon)

    Sorry for the delay, I’ve been a bit busy at the moment.

    Well, I think that you’re on the right way, but I’m not sure why there is still default size of images on your site. Probably something’s wrong, but I have no idea about that.

    This is what I see in my local environment with the above code.

    https://coldbox.miruc.co/wp-content/uploads/2018/01/screenshot-coldbox.vccw-2018-01-28-15-20-56-345-1.png

    Thread Starter caz963

    (@caz963)

    Yes, that’s the sizes I’m seeing at RHR, with only a portion of the image showing. I just ran Regenerate Thumbnails (again) and still, only part of the image is showing. https://www.romantichistoricalreviews.com

    In any case, thank you so much for trying to help – I think I’m going to have to accept that the images on the home page are going to stay the way they are.

    I still really like the theme and will continue to use it ??

    I have one other question – should I open up a new topic?

    Theme Author Toshihiro Kanai

    (@mirucon)

    I apologize that I couldn’t help you, I’ll try to find the solution for this.

    It would be nice to open a new topic, it will be easier to find the information for other users.

    Thread Starter caz963

    (@caz963)

    I really appreciate your trying and your patience!

    I will ask the other question – hopefully an easier to resolve one! in another thread.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Resizing featured images’ is closed to new replies.