I have managed getting the right og:image meta.
In class-opengraph.php change line 233 to look like this:
if ( is_singular( 'attachment' ) ) {
$url = wp_get_attachment_url ( $post->ID );
if ( $url ) {
echo "<meta property='og:image' content='" . $url . "'/>\n";
}
} else {
echo "<meta property='og:image' content='" . esc_url( $img ) . "'/>\n";
}
It will put the curent image link on attachment page to og:image.
What I need is og:description – I have managet to put image description to og:description, but what I really want is to use parent page og:description. So – help please!
OK… I came up with code for og:description to show image description on attachment pages. If anybody needs this…
Just in class-opengraph.php change this code below the line 284:
$ogdesc = apply_filters( 'wpseo_opengraph_desc', $ogdesc );
if ( $ogdesc && $ogdesc != '' ) {
if ( $echo !== false )
echo "<meta property='og:description' content='" . esc_attr( $ogdesc ) . "'/>\n";
else
return $ogdesc;
}
to this:
$ogdesc = apply_filters( 'wpseo_opengraph_desc', $ogdesc );
if ( $ogdesc && $ogdesc != '' ) {
if ( $echo !== false )
echo "<meta property='og:description' content='" . esc_attr( $ogdesc ) . "'/>\n";
else
return $ogdesc;
} elseif ( is_home() ) {
echo "<meta property='og:description' content='YOUR CUSTOM CODE FOR FRONT PAGE (still don't know how to call SEO description)'/>\n";
} elseif ( is_singular( 'attachment' ) ) {
$description = $post -> post_content;
if ( $description ) {
echo "<meta property='og:description' content='" . $description . "'/>\n";
} else {
echo "<meta property='og:description' content='YOUR CUSTOM CODE IF YOU DIDN't SET IMAGE DESCRIPTION'/>\n";
}
}
Hey, thanks for posting this. I was pulling my hair out over that one. However, you are referring to line 233 for the images – depending on which editor I am using the line numbering is different.
Can you post a code excerpt of the class-opengraph.php where that code has to go? THANK YOU !