Extension talk:OpenGraphMeta
Add topicThis page used the LiquidThreads extension to give structured discussions. It has since been converted to wikitext, so the content and history here are only an approximation of what was actually displayed at the time these comments were made. |
Mediawiki version required?
[edit]Hi all, I have just tested this extension on a 1.15.4 MediaWiki installation and I had an error reporting:
Call to undefined method OutputPage::getTitle() in C:\server\xampplite\htdocs\wiki\extensions\OpenGraphMeta\OpenGraphMeta.php on line 65
Installation data:
- MW 1.15.4
- PHP 5.3.0
- MySQL 5.1.41
Extensions installed:
- MultipleUpload 1.0
- Cite r.37577
- DSADate 1.0
- DynamicPageList2 1.7.4
- ImageMap r.35980
- ImageSizeInfoFunctions 1.0.1
- MultipleUploadToolboxItem 0.1
- ParserFunctins 1.1.1
- PropertyTable2 1.2.1
- StringFunctions 2.0.1
- SyntaxHighlight
- GoogleTranslator 0.1
- NewUserEmailNotification 1.5.1
Moreover, inspecting the code, it seems that the extension Description2 is required for properly description tag be evaluated. Is my assumption correct? TIA --GB 11:18, 31 July 2011 (UTC) 10:39, 10 January 2012 (UTC)
- Yes, Description2 has the parsing code to extract a description from the page so OpenGraphMeta uses it instead of duplicating code. —The preceding unsigned comment was added by an unknown user on a unknown date. 10:40, 10 January 2012 (UTC)
- OutputPage::getTitle was added in 1.16; 1.15 is not a supported MediaWiki version anymore, it's no longer receiving security updates and some security holes have been fixed in later versions of MediaWiki. So I see no reason to add 1.15 compat. Dantman 11:53, 31 July 2011 (UTC) 10:40, 10 January 2012 (UTC)
Bug or User Error?
[edit]This didn't seem to output the correct format for the OG meta tags due to the addMeta function called with the BeforePageDisplay hook. Could be my fault. For example, I am getting <meta name="property:og:type" content="article" />
when it should be <meta property="og:type" content="article"/>
. Unless there's something I'm missing, addMeta will only return <meta name="$value1" content="$value2"/>
formatted meta tags.
I am on MediaWiki 1.18.0, PHP 5.2.17, and MySQL 5.1.56--maybe the function addMeta has changed in the latest update? I corrected it by using the hook OutputPageBeforeHTML and the function addHeadItem to output:
foreach( $meta as $property => $value ) {
if ( $value ){
$out->addHeadItem( "OGMeta$i", '<meta property="'.$property.'" content="'.$value.'"/>'.PHP_EOL );
$i++;
}
It seems to work. Thoughts? Lost Student 09:07, 10 January 2012 (UTC) 10:41, 10 January 2012 (UTC)
- Try the trunk or 1.17 version of the extension. The 1.18 version seams to contain a change made after the 1.17 branch but was reverted later on. Daniel Friesen (Dantman) 09:49, 10 January 2012 (UTC) 10:41, 10 January 2012 (UTC)
Suggestion: Change home page default title
[edit]Hello,
This opengraph extension gives the homepage of the wiki the title 'Main Page'. However it might be better to use the site name for this one particular page. It looks better on Facebook this way, and as 'Main page' is a default string, using the site name instead would actually make more sense (to me).
Kevin, Enideo 85.151.118.190 11:41, 9 February 2012 (UTC)
- Implemented that in r111438. Daniel Friesen (Dantman) 01:03, 14 February 2012 (UTC)
Incorrect Namespace
[edit]Installed the extension but when I tried it on a page I changed this code:
((File:Prague.jpg|right|border|thumb|400px|Prague Old Town))
to this:
((File:{{#setmainimage:Prague.jpg}}|right|border|thumb|400px|Prague Old Town))
(Square brackets changed to round brackets for clarity.)
This throws an error:
RepoGroup::findFile recieved an Title object with incorrect namespace Backtrace:
- 0 /home/XXX/public_html/includes/GlobalFunctions.php(3235): RepoGroup->findFile(Object(Title), Array)
- 1 /home/XXX/public_html/extensions/OpenGraphMeta/OpenGraphMeta.php(58): wfFindFile(Object(Title))
- 2 [internal function]: efSetMainImagePH(Object(OutputPage), Object(ParserOutput), Array)
- 3 /home/XXX/public_html/includes/OutputPage.php(1190): call_user_func('efSetMainImageP...', Object(OutputPage), Object(ParserOutput), Array)
- 4 /home/XXX/public_html/includes/OutputPage.php(1203): OutputPage->addParserOutputNoText(Object(ParserOutput))
- 5 /home/XXX/public_html/includes/Article.php(4392): OutputPage->addParserOutput(Object(ParserOutput))
- 6 /home/XXX/public_html/includes/Article.php(1490): Article->outputWikiText('[[File:{{#setma...', true, Object(ParserOptions))
- 7 /home/XXX/public_html/includes/Article.php(4636): Article->doViewParse()
- 8 /home/XXX/public_html/includes/PoolCounter.php(151): PoolWorkArticleView->doWork()
- 9 /home/XXX/public_html/includes/Article.php(1011): PoolCounterWork->execute()
- 10 /home/XXX/public_html/includes/Wiki.php(462): Article->view()
- 11 /home/XXX/public_html/includes/Wiki.php(69): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
- 12 /home/XXX/public_html/index.php(114): MediaWiki->performRequestForTitle(Object(Title), Object(Article), Object(OutputPage), Object(User), Object(WebRequest))
- 13 {main}
Can anyone help?
PS Using MediaWiki 1.17.0 PHP 5.2.12 (apache) MySQL 5.0.95-community 79.35.205.233 14:53, 18 April 2012 (UTC)
- As an update, I upgraded to MW 1.18 and used the 1.18 version of the extension but the problem remains... 79.35.205.233 14:20, 20 April 2012 (UTC)
How do I change og:image in the meta tags?
[edit]I've added the extension to localsetting.php and then I clicked 'edit' and added the code {{#setmainimage:Sunset.jpg}}. However when I click 'facebook like' it doesn't use the image 'sunset.jpg' and I've checked the meta data and there it hasn't changed the og:image source. How do I use this extension? What am I doing wrong? Tech (talk) 09:32, 20 May 2012 (UTC)
- Try changing NewFromDBKey to NewFromTitle, this code seems to rely on an older(?) version of the Title class. rotsee (talk) 20:30, 7 September 2012 (UTC)
- What are you talking about? Title::newFromDBKey still exists and always has. And since we have a DB key it's the right method to use. While Title::newFromTitle does not exist and is conceptually ridiculous. Daniel Friesen (Dantman) (talk) 07:53, 9 September 2012 (UTC)
- Sorry, I just assumed that the reason this extensions doesn't seem to work with newer versions of MW was that it tried calling newFromDBkey like this
Title::newFromDBkey($data['dbkey'], NS_FILE)
, whereas newFromDBkey now only seems to accept one parameter. Using newFromText instead, or something likeTitle::newFromDBkey( "File:" . $data['dbkey'] )
made it work for me. rotsee (talk) 19:02, 17 September 2012 (UTC)- This worked for me as well!! Thanks rotsee. 38.122.6.10 01:36, 13 March 2015 (UTC)
- Thanks! UksusoFF (talk) 17:20, 20 March 2015 (UTC)
- Sorry, I just assumed that the reason this extensions doesn't seem to work with newer versions of MW was that it tried calling newFromDBkey like this
- Oops, did I write newFromTitle? That doesn't make sense, should have been newFromText, of course. :-) rotsee (talk) 19:03, 17 September 2012 (UTC)
- What are you talking about? Title::newFromDBKey still exists and always has. And since we have a DB key it's the right method to use. While Title::newFromTitle does not exist and is conceptually ridiculous. Daniel Friesen (Dantman) (talk) 07:53, 9 September 2012 (UTC)
- Is your wiki publicly available so I can debug? Daniel Friesen (Dantman) (talk) 07:57, 9 September 2012 (UTC)
Current source?
[edit]Hello,
where does the latest source code for this extension reside now? I would like to add a few things for my needs (magic word for changing og:type, og:locale according to page language, and possibly a magic word for adding custom tags).
rotsee (talk) 12:31, 2 August 2012 (UTC)
- It's still in the same spot in svn as it's always been. Someone just went and broke the template. Daniel Friesen (Dantman) (talk) 12:33, 2 August 2012 (UTC)
- Ah, ok rotsee (talk) 12:40, 2 August 2012 (UTC)
How to use ?
[edit]Hi, i post {{#setmainimage:example.png}}
to a wiki page and nothing happens. Facebook doesn't display any picture...
I use it with MW 1.20.0 hollosch (talk) 21:49, 10 March 2013 (UTC)
- You got a wiki that I could look at? There are plenty of situations where an image might not actually show up besides an issue in the extension. Daniel Friesen (Dantman) (talk) 22:05, 10 March 2013 (UTC)
- Yes of course: Look at http://www.geislingen.org
- And i want to use this image: http://www.geislingen.org/wiki/Datei:Stadtwiki_geislingen_an_der_steige.png hollosch (talk) 22:08, 10 March 2013 (UTC)
- Got an example page where the parser function is being used? Daniel Friesen (Dantman) (talk) 22:14, 10 March 2013 (UTC)
- http://www.geislingen.org/wiki/Portal:Wir_schaffen_VERST%C3%84NDNIS hollosch (talk) 22:18, 10 March 2013 (UTC)
- Hmmm... you're right. It's not working. But it should be. I'm not sure why. The only possibility I can guess might be that one of the other extensions might be doing something strange that gets in the way. Daniel Friesen (Dantman) (talk) 22:31, 10 March 2013 (UTC)
- Any ideas which extension(s) do this ? hollosch (talk) 22:33, 10 March 2013 (UTC)
- No clue. It could be one of the less common extensions. Like Wikilog, SGPack, Slimbox, Video, WlFeed, MsUpload, MobileDetect, HeaderTabs, News Channel, etc... Daniel Friesen (Dantman) (talk) 21:15, 11 March 2013 (UTC)
- Ok, i'll check around... hollosch (talk) 21:35, 11 March 2013 (UTC)
- Hi,
- i disabled all extension and it doesn't work... hollosch (talk) 21:58, 11 March 2013 (UTC)
- Hi, we got the same problem and similarly exocitc extensions. But even with these disabled the issue persists. MW 1.20.3 and all extensions on REL_1.20 versions. There simply seems to be no meta tag for og:image while the all other og: tags are there. Anything we can do to narrow down the issue?
- page with setmainimage tag: http://www.entropiaplanets.com/wiki/Entropia_Universe
- page inspected by FB debugger: http://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.entropiaplanets.com%2Fwiki%2FEntropia_Universe
- EDIT: {{#setmainimage:Imagename.jpg}} leads to the display of "Imagename.jpg" as text on the wiki page, no sign that the setmainimage tag is doing anything at all. Psyc0smos (talk) 16:24, 23 April 2013 (UTC)
- No clue. It could be one of the less common extensions. Like Wikilog, SGPack, Slimbox, Video, WlFeed, MsUpload, MobileDetect, HeaderTabs, News Channel, etc... Daniel Friesen (Dantman) (talk) 21:15, 11 March 2013 (UTC)
- Any ideas which extension(s) do this ? hollosch (talk) 22:33, 10 March 2013 (UTC)
- Hmmm... you're right. It's not working. But it should be. I'm not sure why. The only possibility I can guess might be that one of the other extensions might be doing something strange that gets in the way. Daniel Friesen (Dantman) (talk) 22:31, 10 March 2013 (UTC)
- http://www.geislingen.org/wiki/Portal:Wir_schaffen_VERST%C3%84NDNIS hollosch (talk) 22:18, 10 March 2013 (UTC)
- Got an example page where the parser function is being used? Daniel Friesen (Dantman) (talk) 22:14, 10 March 2013 (UTC)
Psyc0smos (talk) 16:25, 23 April 2013 (UTC)
- Same problem here. {{#setmainimage:foo.jpg}} doesn't have any effect on the page's meta tags. Too bad; setting the default page image for Facebook was the only reason I wanted this extension. Unfortunately my wiki's not public so I can't let you troubleshoot. Psychonaut (talk) 10:51, 20 November 2013 (UTC)
- The same problem is here :( My wiki is public so you are very much welcome to troubleshot! :)
- Take any page as http://wikitranslate.org/wiki/Colours_3 Here is the way it looks on Facebook https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwikitranslate.org%2Fwiki%2FColours_3
- I want this image to be posted http://wikitranslate.org/w/images/WikiTranslate-90.png and I added it here http://wikitranslate.org/w/index.php?title=MediaWiki:Sitenotice&action=edit I don't know what else can I do!
- Daniel, thank you so much for the extension! It solved the problem of posting the wrong staff with Google searches! Natkabrown (talk) 21:16, 9 December 2013 (UTC)
- Same problem here. {{#setmainimage:foo.jpg}} doesn't have any effect on the page's meta tags. Too bad; setting the default page image for Facebook was the only reason I wanted this extension. Unfortunately my wiki's not public so I can't let you troubleshoot. Psychonaut (talk) 10:51, 20 November 2013 (UTC)
Default image
[edit]I add this code:
elseif(isset($wgOGLogo)){$meta["og:image"] = wfExpandUrl($wgOGLogo);}
to line 94 and
, $wgOGLogo
to line 63.
I think this way is better. ugorur 19:26, 18 October 2013 (UTC)
- I wouldn't use $wgOGLogo as a name, it doesn't fit a good naming pattern. But that aside could you explain why you think the wiki's standard logo is not an acceptable logo to use for OpenGraph? Daniel Friesen (Dantman) (talk) 22:02, 18 October 2013 (UTC)
Doesn't work for me :(
[edit]I am running MediaWiki 1.22.8. Facebook ignores the "setmainimage tag".
I used it here in the infobox on top:
but Facebook grabs the website logo:
Any idea what I could do?
This is the link to the article: Cycling.
I am grateful for any advice! C.eiermann (talk) 10:07, 31 July 2014 (UTC)
Doesn't work with protocol-agnostic setups
[edit]With $wgServer = "//geowiki.wegge.dk"; Facebook doesn't like the meta tag:
- Object at URL 'http://geowiki.wegge.dk/wiki/Forside' of type 'website' is invalid because the given value '//geowiki.wegge.dk/wiki/Forside' for property 'og:url' could not be parsed as type 'url'.
This can be fixed by changing line 73 (In the 1.23 snapshot to read)
$meta["og:url"] = wfExpandUrl ($title->getFullURL(), PROTO_CURRENT); Wegge (talk) 21:45, 10 August 2014 (UTC)
Can I include this function in a template?
[edit]You suggested in your description: "This works very nicely when you incorporate it into an infobox template making the infobox image the preferred image for 3rd parties to use"
How?
I tried to include it into my infobox: http://www.spd-geschichtswerkstatt.de/wiki/Vorlage:Person Yet the main image isn't set: http://www.spd-geschichtswerkstatt.de/wiki/Franz_Th%C3%B6nnes Kaffeeringe (talk) 23:01, 5 December 2014 (UTC)
- It's work for me with this issue. Demo. UksusoFF (talk) 17:22, 20 March 2015 (UTC)
Fork with Extension:PageImages integration
[edit]I have created a fork of this extension which integrates with Extension:PageImages, so that if both are installed, the intelligent prioritized and automated image selections made by that extension can apply to the og:image property in lieu of other forms of specification (this fork also fixes the php exceptions that are thrown by MediaWiki 1.24 if this extension is installed unmodified, due to there not being a form of Title::newFromDBkey that accepts two parameters). You can find the source code for the customized branch here. QuasarEE (talk) 18:17, 17 April 2015 (UTC)
- Amazing, and amazing timing -- have been updating my wiki for OG starting a couple of days ago, and was scratching my head about how to sort out og:image without wrangling editors into manually doing it. This seems to work great! Only thing I wish I could do now is a mass-resave of articles on our wiki so that it could populate this faster. 78.72.129.219 08:55, 24 April 2015 (UTC)
Not working
[edit]I tried to install this on mediawiki 1.27 and adding {{#setmainimage:Filename.ext}}
to all of my infoboxes but nothing is happening. When I try to share any of my pages it doesn't use the image that I set for it. I also checked the head of the page and it doesn't have an og:image
in the meta tags, but it seems to have the other og
: tags, such as og:type
, og:site_name
, og:title
, and og:url
. Innosflew (talk) 07:30, 25 July 2016 (UTC)
- I have modified 47 line of the OpenGraphMeta.php of the OpenGraphMeta extension from Title::newFromDBkey($data['dbkey'], NS_FILE) to Title::newFromText($data['dbkey'], NS_FILE) and the og:image in the meta tags seems to apear now, but it still not willing to use the infobox image for a few pages. Tribly (talk) 09:01, 25 July 2016 (UTC)
Image tag not working
[edit]I have installed this extension along with TwitterCards. All of the og tags seem to work minus the image tag. The image tag seems to only work on the homepage of the wiki. I have tried googling and tried every suggestion I've found but nothing seems to work at this point. Any help would be greatly appreciated. Thecryptochat (talk) 02:31, 19 September 2017 (UTC)
- I have the same problem. I installed Extension:PageImages and it works like a charm, since it automatically selects the best image for sharing. Ciencia Al Poder (talk) 17:19, 2 February 2018 (UTC)
- I think this is because the generated og:image thumbnail is too small and Facebook refuses to display anything below 200x200. I have provided a fix in this comment. Tinss (talk) 16:04, 6 May 2018 (UTC)
- Hello, currently, the extension does not seem to return any code Meta opengraph image. It would be no longer a problem of image size, but directly a problem of the extension.
- I have only this Meta :
- <meta property="og:type" content="article"/>
- <meta property="og:site_name" content="Analyse Développement Hacking"/>
- <meta property="og:title" content="Accueil Utiliser MediaWiki"/>
- <meta property="og:url" content="https://wiki.visionduweb.fr/index.php?title=Accueil_Utiliser_MediaWiki"/>
- - > https://wiki.visionduweb.fr/index.php?title=Accueil_Utiliser_MediaWiki#Configurer_la_balise_image_OpenGraph_avec_l.27extension_OpenGraphMeta
Zer00CooL (talk) 11:44, 15 March 2019 (UTC)
setmainimage keeps grabbing a thumb instead of actual image
[edit]The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
When I put down {{#setmainimage:Filename.ext}} what I get in the og:image is not the actual image but a thumb of that image.
Example:
If I put down {{#setmainimage:Filename.png}} I get:
<meta property="og:image" content="http://sitename.com/wiki/images/thumb/5/5d/Filename.png/105px-Filename.png" />
instead of simply
<meta property="og:image" content="http://sitename.com/wiki/images/5/5d/Filename.png" />
Any ideas what can cause this? Tenzel Kim (talk) 13:19, 26 March 2018 (UTC)
- It's coded like this, forcing a thumb that fits 300x100: https://github.com/wikimedia/mediawiki-extensions-OpenGraphMeta/blob/master/OpenGraphMeta.class.php#L76
- I don't know why that restriction, though Ciencia Al Poder (talk) 17:57, 26 March 2018 (UTC)
- Actually, 300x100 is now too small a value for Facebook, which required at least 200x200 for the og:image tag. I've submitted a bug on phabricator but if you want to fix the code yourself find OpenGraphMeta.class.php and change line 76 to:
$meta['og:image'] = wfExpandUrl( $mainImage->createThumb( 1200, 630 ) );
Tinss (talk) 16:02, 6 May 2018 (UTC)- The bug was fixed in change 431322. For those still having an issue with this, simply reinstall the extension. Tinss (talk) 08:07, 7 May 2018 (UTC)
DISPLAYTITLE
[edit]This extension should use the DISPLAYTITLE instead of the actual page title, if provided on the page. Ciencia Al Poder (talk) 18:35, 14 September 2018 (UTC)
The {{#setmainimage:}} no longer works...
[edit]I've just upgraded to 1.31 and now all my pages that have {{#setmainimage:}} on them, no longer have images in the open graph data. Anyone know how to make this work again? Titanshadow (talk) 22:26, 20 December 2018 (UTC)
- Currently the same thing on mediawiki 1.32.0 extension does not seem to work properly, the image tag is not taken into account. I only have the following TAGs, using this extension:
- <meta property="og:type" content="article"/>
- <meta property="og:site_name" content="Analyse Développement Hacking"/>
- <meta property="og:title" content="Accueil Utiliser MediaWiki"/>
- <meta property="og:url" content="https://wiki.visionduweb.fr/index.php?title=Accueil_Utiliser_MediaWiki"/>
- But, i have add the image !
- -> https://wiki.visionduweb.fr/index.php?title=Accueil_Utiliser_MediaWiki#Configurer_la_balise_image_OpenGraph_avec_l.27extension_OpenGraphMeta Zer00CooL (talk) 11:47, 15 March 2019 (UTC)