• Resolved tobaco

    (@tobaco)


    Hi,

    first of all, thanks for this great Plugin!

    Working great so far in generating the images. But right now my Yoast Seo plugin doesn’t output the new generated image. It still uses the featured image.

    Do I have to take care of this myself (using wpseo_opengraph_image & wpseo_twitter_image hooks) or is your plugin supposed to do this?

    If the plugin will take care of this, it would also be great, to have the possibility to overwrite the generated image with something else via the seo settings. (If this is doable …)

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Anton Lukin

    (@antonlukin)

    Hi,
    thank you for your message. I need some time to clarify the details.
    As far as I remember, right now the plugin cannot interact with others, so you will most likely have to use the hooks you provided and throw the generated image there. Use sharing_image_poster function to get an image and sharing_image_poster_src to get your image with sizes.

    Thread Starter tobaco

    (@tobaco)

    Hi and thanks!

    this is what i use now to set the og:image for Yoast SEO.

    
    /* Change Open Graph image URLs in Yoast SEO
     */
    
    function change_opengraph_image_url( $url ) {
    	$queried_object = get_queried_object();
    	if(is_object($queried_object) && $queried_object->ID){
    		// check if there is an custom image set
    		$hasYoastImage = get_post_meta( $queried_object->ID, '_yoast_wpseo_opengraph-image-id', true );
    
    		if($hasYoastImage) return $url;
    
    		$sharingImage = sharing_image_poster_src($queried_object->ID);
    		if(is_array($sharingImage) && isset($sharingImage[0])){
    			$url = $sharingImage[0];
    		}
    	}
    	return $url;
    }
    
    add_filter( 'wpseo_opengraph_image', 'change_opengraph_image_url' );
    
    /**
     * @param bool $hide_header Set true to hide poster meta.
     */
    function hide_sharing_meta( $hide_meta ) {
        return true;
    }
    
    add_filter( 'sharing_image_hide_meta', 'hide_sharing_meta' );
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Yoast compatibility’ is closed to new replies.