Problem/Motiviation

When an Image field field_image is provided a default value on the field settings, but on the node no image is selected for the field, then the url, height, and weight attributes are not displayed with the metatags.

Replication steps:

  1. Add field_image to the Article content type
  2. Provide a default value for the field under field settings
  3. Create a new node of type Article
  4. Populate the field by selecting an image from the media library
  5. Setup the Schema.org Article meta tag so that the [node:field_image:large:url]is set as the url under any ImageObject
  6. Save and view the page to observe the correct attributes added to the page
  7. Edit the page again and remove the selected image
  8. Save and view the page to observe the url attribute is missing from the ImageObject

Current meta tag output

"image": {
  "@type": "ImageObject",
  "representativeOfPage": "True"
},

Expected meta tag output (with no image selected)

"image": {
  "@type": "ImageObject",
  "representativeOfPage": "True",
  "url": "https://some-default/url/large/cloud.jpg?itok=W4d08z8M",
  "width": "400",
  "height": "260"
},

Expected meta tag output (with image selected)

"image": {
  "@type": "ImageObject",
  "representativeOfPage": "True",
  "url": "https://selected-image/url/large/cloud.jpg?itok=W4d08z8M",
  "width": "400",
  "height": "260"
},

Proposed Solution

  1. Add validation to check if image is populated then use the image. If not, then retrieve the default image from field setting
  2. If we cannot get the default image, then do not display the ImageObject attribute

Remaining tasks

  1. Add patch to allow for retrieving the default value when image is empty

Comments

drup16 created an issue. See original summary.

drup16’s picture

Issue summary: View changes
drup16’s picture

Version: 8.x-1.2 » 8.x-1.3

Updating version as issue still exists in v8.x-1.3

drup16’s picture

Issue summary: View changes
drup16’s picture

Issue tags: -metatag, -Field API
drup16’s picture

Version: 8.x-1.3 » 8.x-1.4
DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)

Is this still a problem with v8.x-2.x or 3.0.x? The 8.x-1.x branch is no longer supported. Thank you.