Created
November 10, 2019 18:34
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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