Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1157: Display schema.org image data for 'attachment' post type #1176

Merged
merged 3 commits into from
May 27, 2018

Conversation

kienstra
Copy link
Contributor

On 'attachment' pages in Native AMP, there's no schema.org data for the image.

This adds a conditional to check for the post type of 'attachment.'

It's possible that the attachment is a video, like a .mov file. In that case, it won't return an image.

As reported in this support topic: https://wordpress.org/support/topic/structured-data-error-for-attachment-pages-media/

Closes #1157.

As reported on a support topic, on Native AMP,
on 'attachment' pages, there's no schema.org
data for the image.
So add a conditional to check for this post type.
It's possible that the attachment is a video,
like a .mov file.
In that case, it won't return an image.
wp_get_attachment_image_src() will return false.
@see https://wordpress.org/support/topic/structured-data-error-for-attachment-pages-media/
There was a failed Travis build.
So align the = signs with line 387.
@westonruter westonruter added this to the v0.7.2 milestone May 25, 2018
@@ -524,6 +524,8 @@ function amp_get_post_image_metadata( $post = null ) {

if ( has_post_thumbnail( $post->ID ) ) {
$post_image_id = get_post_thumbnail_id( $post->ID );
} elseif ( 'attachment' === $post->post_type ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the attachment isn't an image? I think this should also include wp_attachment_is( 'image', $post )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, commit 15ea3d ensures the attachment is an image.

Props @westonruter for the conditional check.
This ensures that the attachment isn't another type,
like a video.
In that case, wp_get_attachment_image_src() won't return

image data.
@westonruter westonruter merged commit ab199da into 0.7 May 27, 2018
@swissspidy swissspidy deleted the attachment-schema branch June 18, 2019 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants