Problem/Motivation

In the author field of the Book schema type, the logo property should be replaced with the image property. This is because Google’s Schema Snippets tests require the image field for the Person type and do not accept logo as a valid property.

Proposed resolution

Replace the ImageObject property “logo” with “image”.

CommentFileSizeAuthor
#2 Schema.png67.39 KByouness ka

Comments

pearls created an issue. See original summary.

youness ka’s picture

StatusFileSize
new67.39 KB

I ran into this same problem, but for the Article author field, where Google also expects Person.image instead of logo.

As a workaround (and a relatively clean extension of the existing API), I added an image sub-property to the organization property type via hook_schema_metatag_property_type_plugins_alter(). Since the schema_article_author tag uses property_type = "organization" and can represent either Person or Organization, this makes a new image field appear in the Author complex widget, which I can then map via Metatag tokens.

Here’s the snippet:

/**
 * Implements hook_schema_metatag_property_type_plugins_alter().
 */
function MYMODULE_schema_metatag_property_type_plugins_alter(array &$definitions): void {
  if (empty($definitions['organization'])) {
    return;
  }

  if (empty($definitions['organization']['sub_properties']['image'])) {
    $definitions['organization']['sub_properties']['image'] = [
      // Use the simple URL property type so the JSON-LD will output:
      //   "image": "https://example.com/author.jpg"
      // instead of an ImageObject.
      'id' => 'url',
      'label' => t('image'),
      'description' => t('The image URL of the person or organization (used for Article/Book author).'),
      'tree_parent' => [],
      'tree_depth' => 0,
    ];
  }
}

After clearing caches, the Author widget exposes an image field which I can set to a token for the author picture URL. The resulting JSON-LD for the author becomes:

"author": {
  "@type": "Person",
  "name": "…",
  "image": "https://…/author.jpg",
  "sameAs": [ "…" ]
}