• Google Search Console is showing video related errors due to its inability to determine the thumbnail image for the video in the gallery.

    This can be resolved by adding VideoObject schema.org markup.

    Option 1: add this to the plugin, maybe with a setting to enable/disable.

    Option 2: add it as integration for Yoast SEO, Rank Math, etc.

    Option 3: provide an action or filter hook, which receives all the required information (name, description, thumbnailUrl, uploadDate, contentUrl OR embedUrl). This will allow developers to add their own markup.

    For this option, it’s best to run an action during wp_head, to enable writing the markup into the HEAD section of the page. If using a filter, it will simply allow adding the markup along with the video itself.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author NikHiL Gadhiya

    (@nikhilgadhiya)

    Hello @galbaras,
    We have provided an option to add a video schema in the product edit page.
    Please update the plugin with the latest version.

    Thank You.

    Thread Starter Gal Baras

    (@galbaras)

    Thank you for this, @nikhilgadhiya, but it’s better to have a global setting for schema generation, and to have the upload date, name and description fetched automatically.

    Rank Math Pro does this automatically when it discovers a video on a page, so I know it’s possible.

    Thread Starter Gal Baras

    (@galbaras)

    @nikhilgadhiya If it helps, see https://rankmath.com/kb/content-analysis-api/ for Rank Math integration.

    Also, here’s an action hook I’ve written to automate creating reasonable schema records when those fields are left blank:

    add_action( 'save_post', 'custom_save_wc_video_schema', 15 );
    function custom_save_wc_video_schema( $post_id ) {
    	$nonce_name   = isset( $_POST['nickx_video_url_nonce'] ) ? $_POST['nickx_video_url_nonce'] : '';
    	$nonce_action = 'nickx_video_url_nonce_action';
    	if ( ! wp_verify_nonce( $nonce_name, $nonce_action ) ) {
    		return;
    	}
    	$product_video_urls = $_POST['nickx_video_text_url'];
    	if ( ! is_array( $product_video_urls ) ) {
    		$product_video_urls = [ $product_video_urls ];
    		update_post_meta( $post_id, '_nickx_video_text_url', $product_video_urls );
    	}
    	if ( ! $product_video_urls[0] ) {
    		return;
    	}
    	$schema = isset( $_POST['video_schema'] ) ? $_POST['video_schema'] : [];
    	$date = isset( $_POST['nickx_video_upload_date'] ) ? $_POST['nickx_video_upload_date'] : [];
    	$name = isset( $_POST['nickx_video_name'] ) ? $_POST['nickx_video_name'] : [];
    	$description = isset( $_POST['nickx_video_description'] ) ? $_POST['nickx_video_description'] : [];
    	foreach ( array_keys( $product_video_urls ) as $key ) {
    		$schema[$key] = 'yes';
    		if ( ! isset( $date[$key] ) || ! $date[$key] ) {
    			$date[$key] = get_post_time( 'Y-m-d', false, $post_id, true );
    		}
    		if ( ! isset( $name[$key] ) || ! $name[$key] ) {
    			$name[$key] = get_the_title( $post_id );
    		}
    		if ( ! isset( $description[$key] ) || ! $description[$key] ) {
    			$description[$key] = get_the_title( $post_id ) . ' by Tania Olsen Designs';
    		}
    	}
    	update_post_meta( $post_id, '_video_schema', $schema );
    	update_post_meta( $post_id, '_nickx_video_upload_date', $date );
    	update_post_meta( $post_id, '_nickx_video_name', $name );
    	update_post_meta( $post_id, '_nickx_video_description', $description );
    }
    
    Thread Starter Gal Baras

    (@galbaras)

    Hi Nikhil,

    For some reason, line 123 of class-rendering.php calls wp_get_attachment_image_url() without specifying an image size, which defaults to thumbnail. Unfortunately, this isn’t a good size for various purposes.

    Please change this to wp_get_attachment_image_url( $video_thumb_ids[$key], 'full' );

    Alternatively provide a filter for the thumbnail size and/or for the output of nickx_get_nickx_video_schema() (it’s good practice to have both).

    One more thing that can help override things is making $nickx_rendering_obj global, so that its actions can be removed.

    Thank you,
    Gal

    • This reply was modified 1 year, 5 months ago by Gal Baras.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘(How to) Add Video Schema’ is closed to new replies.