Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Hesham Zebida

    (@hishaman)

    Since I am trying to keep the plugin settings simple as possible, I won’t be adding such feature or other new settings to the plugin unless it’s super important.

    So, instead of having a new settings, you can use a simple function to add, modify or override markup output and hook it to a filter.

    P.S. I don’t really recommend setting a default image just to fix the Google Structured Data Testing Tool error, mostly this is not the right way to do it since every Article should have a unique and relevant image, a default image isn’t unique, nor relevant to anything, really!

    You can use a filter to set default image when there is no Featured image presented in post, here is an example that you can use within your Theme’s functions.php file:

    function schema_wp_set_default_image_12345( $json ) {
    
    	// If image is already defined,
    	// return our $json array and do not do anything
    	if ( isset($json['media']) && ! empty($json['media']) ) return $json;
    
    	// There is no image defined in Schema array,
    	// set default ImageObject, url, width, and height
    	$json['media']['@type'] = 'ImageObject'; // schema type, do not change this!
    	$json['media']['url'] = 'https://default-image-url.png'; // set default image url
    	$json['media']['width'] = 720; // set image width
    	$json['media']['height'] = 400;	// set image height
    
    	return $json;
    }
    add_filter('schema_json', 'schema_wp_set_default_image_12345');

    You need to use your own values for URL, Width, and Height.

    I hope this helps.

    Thread Starter krumch

    (@krumch)

    Thanks ??

    Plugin Author Hesham Zebida

    (@hishaman)

    No problem!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Feature request’ is closed to new replies.