• Resolved XstreamThemes

    (@xstreamthemes)


    Hi guys,

    great plugin, but have one issue. I see that you replaced the way how to change default OG image address that was replaced with the_seo_framework_og_image_args filter in previous version…

    Do you have code example how to change OG image on 4.X version that’s doing similar thing as:

    add_filter('the_seo_framework_og_image_args', function($args) {
        $args['image'] = 'https://cdn.roots.io/app/uploads/roots-og.png';
    
        return $args;
    });
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello 🙂

    Since TSF v4.0, there’s a new image generator. You can find an example filter in the API docs.

    To achieve what you’ve had before updating, I believe this will do (untested!):

    add_filter( 'the_seo_framework_image_generation_params', function( $params = [], $args = null, $context = 'social' ) {
    
    	// Let's not mess with non-social sharing images.
    	if ( 'social' !== $context ) return $params;
    
    	$params['cbs'] = array_merge(
    		[ 'custom' => 'my_custom_tsf_singular_image_generator' ], // prepend custom generator
    		$params['cbs'],
    	);
    
    	return $params;
    }, 10, 3 );
    
    function my_custom_tsf_singular_image_generator( $args = null, $size = 'full' ) {
    	yield [
    		'url' => 'https://cdn.roots.io/app/uploads/roots-og.png',
    		'id'  => 0,
    	];
    }
    Thread Starter XstreamThemes

    (@xstreamthemes)

    Thanks, works great!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom OG image’ is closed to new replies.