Black Friday Sale! Get up to $30 off GP Premium! Learn more ➝

[Resolved] Change single page featured image

Home Forums Support [Resolved] Change single page featured image

Home Forums Support Change single page featured image

  • This topic has 5 replies, 3 voices, and was last updated 2 years ago by Tom.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #1066741

    Hi Tom,

    I am using add_image_size() to create a custom size that won’t waste bandwith/time for anybody.

    How can I hook into the code of the featured image (in the single page) so that the get_the_post_thumbnail() function uses my custom size?

    Or maybe there’s a feature somewhere that I am not seeing.

    Best regards,

    Customer Support

    Well I was really looking into the hook. On the homepage, I do it easily a piece of code Tom gave me :

    add_filter('generate_featured_image_output', function () {
        $isHot = false;
        if (isHot(get_the_id())) {
            $isHot = '<span class="hotpost"></span><span class="hottexte">En vedette!</span>';
        return sprintf( // WPCS: XSS ok.
            '<div class="post-image">
                <a href="%2$s">
                apply_filters('generate_page_header_default_size', '<strong>liste</strong>'),
                    'itemprop' => 'image',

    But I guess that *could* do the same and be much cleaner.

    However, I have a few issue with using that built-in feature.

    1) I have no “image_processing_queue” cron events.

    2) When I am looking at the lists of available thumbnail I have inside the theme, I have nothing matching what I put in Β« Customize / Layout / Blog / Featured Image / Posts Β»

    So either I have something broken or it won’t play well with the image optimization tools I use.

    Lead Developer
    Lead Developer

    You should just be able to do this:

    add_filter( 'generate_page_header_default_size', function( $size ) {
        if ( is_page() ) {
            $size = 'your-custom-size';
        return $size;
    } );

    I’m not a fan of the current image resizer, either. I have a better idea I’ll be implementing in 2020 πŸ™‚


    Ahhh thank you very much Tom. I am not sure why it didn’t work yesterday as I was testing something similar.

    Oh well, thanks again and have a nice day πŸ™‚

    Lead Developer
    Lead Developer

    You’re welcome! You too πŸ™‚

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.