?
Referenced as Pull Request for: # 10682
avatar mbabker
mbabker
29 May 2016

Steps to reproduce the issue

Add open graph metadata using JDocument::setMetaData()

$document->setMetaData('og:image', 'https://cdn.joomla.org/images/Joomla_logo.png');

Expected result

When rendering, the resulting meta tag per http://ogp.me/ should be:

<meta property="og:image" content="https://cdn.joomla.org/images/Joomla_logo.png" />

Actual result

When rendering, the resulting meta tag is:

<meta name="og:image" content="https://cdn.joomla.org/images/Joomla_logo.png" />

Additional comments

The use of JDocument::addCustomTag() is required to mitigate this due to the lack of native support.

avatar mbabker mbabker - open - 29 May 2016
avatar n9iels
n9iels - comment - 29 May 2016

We could add a new parameter to the JDocument::setMetaData() that can be set to true for open graph. (See this file and line https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/document/document.php#l424).

And for the head renderer a check to generate the correct html (see this file and line https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/document/renderer/html/head.php#L92)

avatar brianteeman brianteeman - change - 29 May 2016
Category Libraries
avatar brianteeman brianteeman - change - 29 May 2016
Labels Added: ?
avatar andrepereiradasilva
andrepereiradasilva - comment - 29 May 2016

you also need to add the open graph namespace in the html tag right?

avatar mbabker
mbabker - comment - 29 May 2016

I honestly don't know but if so that presents another issue in that there
is absolutely no way without an onAfterRender plugin to set stuff on the
base HTML tag.

On Sunday, May 29, 2016, andrepereiradasilva notifications@github.com
wrote:

you also need to add the open graph namespace in the hmtl tag right?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#10671 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAWfoXsdxk39_GiKh5vuApXDcZAVRk6Iks5qGfjwgaJpZM4IpVSU
.

avatar andrepereiradasilva
andrepereiradasilva - comment - 29 May 2016

we would need some sort of an jdoc include in the template for that
Something like:

<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"<jdoc:include type="namespaces" />>

And them make JDocument render those with something like

$doc->addHtmlNameSpace($attribute, $value);

$doc->addHtmlNameSpace("prefix", "og: http://ogp.me/ns#");
$doc->addHtmlNameSpace("prefix", "fb: http://ogp.me/ns/fb#");

So it can render

<!DOCTYPE html>
<html lang="en-gb" dir="ltr" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">

Since html is extensible trough prefixes/namespaces it would be godd if joomla could deal with this.

avatar Bakual
Bakual - comment - 30 May 2016

In my extension it seems to work without the namespace and the Facebook debug tool also doesn't complain about the missing namespace.

avatar andrepereiradasilva
andrepereiradasilva - comment - 30 May 2016

yes it works, but it's not valid HTML code if you don't add the namespace right?
See http://ogp.me

avatar Bakual
Bakual - comment - 30 May 2016

The namespace isn't needed for it to be valid HTML. OpenGraph uses regular HTML elements (namely the <meta> tag). It's only the values which define the OpenGraph functionality.

avatar andrepereiradasilva
andrepereiradasilva - comment - 30 May 2016

you're right, just test it in the validator (https://validator.w3.org/#validate_by_input) and says it's valid HTML without the prefix.

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta property="og:title" content="The Rock" />
<meta property="og:type" content="video.movie" />
<meta property="og:url" content="http://www.imdb.com/title/tt0117500/" />
<meta property="og:image" content="http://ia.media-imdb.com/images/rock.jpg" />
</head>
<body>
<p>test</p>
</body>
</html>

IIRC sometime ago the validator add issues with that.
But since now it says it's valid i think you're right.

So it seems for this case you don't need the namespace afterall.

avatar andrepereiradasilva
andrepereiradasilva - comment - 30 May 2016

@mbabker please test #10682

avatar brianteeman brianteeman - change - 31 May 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-05-31 20:38:50
Closed_By brianteeman
avatar brianteeman
brianteeman - comment - 31 May 2016

Closed as we have a a PR #10682


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10671.

avatar brianteeman brianteeman - close - 31 May 2016

Add a Comment

Login with GitHub to post a comment