• Hi,
    I am looking for way to set default image size for Post Featured Image block.
    I already tried to do it with wp.hook.addfilter but this doesnt work properly.
    In gutenberg editor attribute for block is set correctly but on page this doesnt work and images are in full resolution.
    Is there any other option to set default size?

    ((wp) => {
        const setDefaultSizeForPostFeaturedImage = (settings, name)=>{
            if(name == "core/post-featured-image"){
                settings.attributes.sizeSlug = {
                    type:'string',
                    default: 'thumbnail'
                }
            }
            return settings;
        }
    
        wp.hooks.addFilter(
            'blocks.registerBlockType',
            'ji/remove-drop-cap',
            setDefaultSizeForPostFeaturedImage
        );
    
    })(window.wp);
Viewing 1 replies (of 1 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Hi @zkazag – it may not be possible to set the default size via theme.json. I asked @greenshady to take a look, and he whipped up a quick PHP function for you instead:

    add_filter( 'post_thumbnail_size', function( $size ) {
    	if ( 'post-thumbnail' === $size ) {
    		$size = 'large'; // change to whatever size is preferred.
    	}
    
    	return $size;
    } );

    This could then be put in a functionality plugin or a (child) theme’s functions.php.

    Perhaps @poena might know definitively whether it’s possible to go the theme.json route with this one.

Viewing 1 replies (of 1 total)

The topic ‘Default Post Featured Image size’ is closed to new replies.