Skip to content

Instantly share code, notes, and snippets.

@sybrew
Created November 10, 2019 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sybrew/247ab95e345a4159da958095ec8ea21e to your computer and use it in GitHub Desktop.
Save sybrew/247ab95e345a4159da958095ec8ea21e to your computer and use it in GitHub Desktop.
Removes content-images for Schema-type generators in The SEO Framework. Affects Articles markup.
<?php
// Don't include the PHP tag if PHP is already active...
/**
* Adjusts image generation parameters to exclude content-images for Schema-type generators.
*
* @param array $params : [
* string size: The image size to use.
* boolean multi: Whether to allow multiple images to be returned.
* array cbs: The callbacks to parse. Ideally be generators, so we can halt remotely.
* array fallback: The callbacks to parse. Ideally be generators, so we can halt remotely.
* ];
* @param array|null $args The query arguments. Contains 'id' and 'taxonomy'.
* Is null when query is autodetermined.
* @param string $content The query context.
* @return array $params
*/
add_filter( 'the_seo_framework_image_generation_params', function( $params = [], $args = null, $context = 'social' ) {
// Let's only adjust 'schema' type images.
if ( 'schema' !== $context ) return $params;
// Detecting the query is redundant...
// Unset the content image-generator callback.
unset( $params['cbs']['content'] );
return $params;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment