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

Projects
None yet
2 participants
@kienstra
Collaborator

kienstra commented May 25, 2018

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.

kienstra added some commits May 25, 2018

Display schema.org image data for 'attachment' post type.
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/
Align = signs vertically.
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 ) {

This comment has been minimized.

@westonruter

westonruter May 25, 2018

Member

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

This comment has been minimized.

@kienstra

kienstra May 26, 2018

Collaborator

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

Check that 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

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment