Closed (fixed)
Project:
Open Graph meta tags
Version:
7.x-2.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Sep 2011 at 18:44 UTC
Updated:
24 Jul 2015 at 15:54 UTC
Jump to comment: Most recent
Comments
Comment #1
designguru commentedIncase anyone is looking for the same functionality, I hacked up some php in my page.tpl.php file's header section - just below the page title so that this code gets loaded before the module-powered og tags.
The above will print a field called 'logo' in the 'blog' type's og:image header declaration and still let the module do its thing - which means that Facebook will offer you two options for a thumbnail image - the imagefield powered one from the solution above, and the de facto image for your site as set in the module settings.
:)
Cheers,
Qasim
Comment #2
venusrising commentedYou are a genius. Been killing myself over this. BTW to tell Facebook a default image without a module we did
in template.php
function ourtheme_preprocess_node(&$vars, $hook) {
global $user;
if(arg(0) == 'node') {
if(!empty($node->field_ourimage[0]['view'])) {
drupal_set_html_head('
href="'.check_url($node->field_ourimage[0]['view']).'" />');
} else {
drupal_set_html_head('
href="http://www.xxx.com/files/xxx_logo.png" />');
}
}
So, with your hack we get the node image first and our logo if empty OR someone wants to choose it.
We also added meta property="og:type" content="article"/ (had to remove arrows in this ost as it would not print but you need the <> also) so we had one more graph tag of type
THANKS!
Comment #3
k3vin_nl commentedI agree, it would be great to select a default way to select the image per node type. For example a choose a cck image field per node-type.
For now we solved it like this in preprocess_page().
If we have a node with cck field-image the default open graph image tag is removed and a new one added. Would be great if this could be done via a configurable setting!
Comment #4
venusrising commentedNow the question would be how to get this to work for a frontpage view. We have a custom tpl but it does not respect the image.
Comment #5
hiddentao commentedI think what's needed is a hook which allows you to modify the value of the og:image tag for each node just before it gets output.
Comment #6
hiddentao commentedAdded a new hook in latest dev release: og_tag_render_alter
Documentation in opengraph_meta_test_module.module
Comment #7
windm commentedHi there!
Is it really required to put things in the page.tpl or to rewrite things as a preprocess?
I have the same requirement (to have the #1 image of a node as the default thumbnail for fb sharing) and the same situation/experience:
- OG Meta tags takes always(!) the "fallback image" that is defined at admin/content/opengraph_meta/settings if I don´t edit the node manually
- in the node/*/edit form I find the "Open Graph meta tags" settings where all existing CCK-imagefields are offered as the thumbnail... so I simply need to check the radio-button and everything is fine (means the right image is posted to fb!)
- for this reason, users without permissions to edit the OG meta tags, can´t change the thumbnail...
So all I would ask for, is that the first available radio button should be checked by default...
Comment #8
shaneonabike commented+1 this would be super useful to be honest since the scraping off my site is producing lots of useless images :( Also weirdly enough I couldn't get your hook to invoke after many flushes and different attempts... strange.
Comment #10
torotil commentedVersion 7.x-2.x now builds on metatag. So it now is possible to set a default image per bundle/content-type and still use the image-select from opengraph_meta.