Bild fehlt und ist erforderlich - Wordpress AMP Structure fügt kein Bildattribut hinzu
Wenn ich meine WordPress-Posts mit dem Structured Data Testing Tool von Google überprüfe, wird der folgende Fehler angezeigt:
"Image: missing and required"
Ich habe das offizielle WordPress-AMP-Plugin installiert, das die AMP-Seiten für mich generiert hat. Das Problem ist, dass das Attribut "image" für @ nicht beliebt isBlogPosting
.
Im Plugin gibt es einen Code, von dem ich denke, dass er generiert werden sollte, der jedoch nirgendwo ausgeführt wird:
private function get_post_image_metadata() {
$post_image_meta = null;
$post_image_id = false;
if ( has_post_thumbnail( $this->ID ) ) {
$post_image_id = get_post_thumbnail_id( $this->ID );
} else {
$attached_image_ids = get_posts( array(
'post_parent' => $this->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'posts_per_page' => 1,
'orderby' => 'menu_order',
'order' => 'ASC',
'fields' => 'ids',
'suppress_filters' => false,
) );
if ( ! empty( $attached_image_ids ) ) {
$post_image_id = array_shift( $attached_image_ids );
}
}
if ( ! $post_image_id ) {
return false;
}
$post_image_src = wp_get_attachment_image_src( $post_image_id, 'full' );
if ( is_array( $post_image_src ) ) {
$post_image_meta = array(
'@type' => 'ImageObject',
'url' => $post_image_src[0],
'width' => $post_image_src[1],
'height' => $post_image_src[2],
);
}
return $post_image_meta;
}
Wie kann ich das Image-Tag für jeden Beitrag mit diesem AMP WordPress-Plugin füllen? Ich möchte, dass die Seite das Structured Data Testing Tool besteht, damit er auch die AMP-Validierung bestehen kann.
Aktualisiere: Das Bild wird nicht angezeigt, da der Beitrag kein eingebettetes Bild enthält. Gibt es eine Möglichkeit, ein Standard-Image einzufügen, falls es keines gibt, so dass es die AMP / Schema-Validierung besteht?