Hi Thomas,
The plugin by default generates meta tags for all attached and embedded (only Flickr is currently supported) images. There are no plans to change this behavior. Perhaps an option will be added in the future to generate meta tags only for the featured image, but this is not a guarantee that the aforementioned services will use that one.
At the time of writing the plugin, it was unclear which image would be used as the default by FB/G+. Some people claimed the first or last one of the list was preferred, while others claimed that the services used the image with the most suitable size. It is actually really difficult to say which image is the right one and which is the wrong one.
So, unless there is some solid information about this issue, I think it is pointless to make any changes to the order the plugin generates image meta tags, which is:
1) The featured image
2) Other attached images (locally hosted)
3) Embedded images (currently supports only Flickr)
This order was the one that made sense, so I decided to go ahead with that.
You can always experiment by filtering the generated opengraph meta tags programmatically (1st one is always the featured image) and see what happens. Please, see example 1 in the description page.
George
Hi George,
thanks for your fast and informative reply (as usual)!
I thought about it: Is it possible to exclude single posts / pages from the automatic generation of meta data? (I know this possible for specific post types, as described in example 2.)
If I could do this, then I would just put my individually changed meta tags in the meta tags box on the edit screen and try out a few things…
Thanks a lot
Thomas
Hello Thomas,
I thought about it: Is it possible to exclude single posts / pages from the automatic generation of meta data? (I know this possible for specific post types, as described in example 2.)
It can be done as shown in example 2, in which an empty array should be returned:
function limit_metadata_to_post_types( $post_types ) {
return array();
}
add_filter( 'amt_supported_post_types', 'limit_metadata_to_post_types', 10, 1 );
If I could do this, then I would just put my individually changed meta tags in the meta tags box on the edit screen and try out a few things…
Also, if you just want to remove the ‘og:image’ metatags from the Opengraph metadata and experiment by adding your own ‘og:image’ meta tags in the ‘Full Meta Tags’ box in the post editing screen (need to be enabled in plugin settings under ‘Metabox Features’), this code could help:
function amt_opengraph_no_images( $metatags ) {
$og_final = array();
foreach ( $metatags as $metatag ) {
if ( strpos($metatag, 'og:image') === false ) {
$og_final[] = $metatag;
}
}
return $og_final;
}
// Suppress width/height/type meta tags for images for easier exclusion
add_filter( 'amt_extended_image_tags', 'amt_return_false', 10, 1 );
// Exclude 'og:image' meta tags from OpenGraph metadata
add_filter( 'amt_opengraph_metadata_head', 'amt_opengraph_no_images', 10, 1 );
George
Hi Thomas,
If you don’t get expected results by using the code above, please let me know.
George
Hi George,
I just put the following code into the functions.php of my (child) theme:
function limit_metadata_to_post_types( $post_types ) {
return array();
}
add_filter( ‘amt_supported_post_types’, ‘limit_metadata_to_post_types’, 10, 1 );
Result: While the plugin itself is still activated (I can get into the options page), the meta data seems to be removed from all posts & pages and there are no fields from your plugin in the edit screens visible.
So something obviously went “wrong” – should I have modified the code?
Thanks
Thomas
No worries, metadata is fine, it’s just not displayed. Using this method apparently does not give the expected result.
You will have to use the second method to stop generating the og:image meta tags.
Or to completely stop the generation of Opengraph meta tags, add the following:
function amt_no_opengraph( $metatags ) {
return array();
}
add_filter( 'amt_opengraph_metadata_head', 'amt_no_opengraph', 10, 1 );
Hope this helps.
George
PS: The provided sample code does not affect the stored data in any way.
… or just disable it in the configuration panel (where is my mind..)
Using this method apparently does not give the expected result.
I’ll look into this at some later time.
I will try out disabling OpenGraph meta tags and inserting my own tags later and get back with the results.
If you look at this issue again: Just having the option to disable automatic meta tags generation with single posts / pages via posts / page ID while still having the meta tags box in the edit screen to insert one’s own tags would be most handy, I’d guess IMHO.
Thanks again!
Thomas
Just tried it… the only og:image tags in the code of the page were of the image I wanted to be displayed when shared via facebook. It did not work! Facebook still used the image that is inserted in the post…hmpf?!
I’d suggest doing the following to make sure: Add a single og:image meta tag pointing to the image you want to use (make sure the image size follows the specs) and then use facebook’s debug tool to get a new scrape of the page. This will force the service to refresh its cache.
Hope this helps
George
Hello Thomas,
Any new findings about the issue?
Hi George,
thanks so much for caring! 🙂
I’m sorry but real life got me on my knees… will post here when I can!
Thomas
No problem. Please take your time. I’m also posting on these forums whenever I have the time to do so. 🙂
George