oscarotero / Embed

Get info from any web service or page
MIT License
2.08k stars 312 forks source link

og:type = article #205

Closed JanPetterMG closed 7 years ago

JanPetterMG commented 7 years ago

Why is og:type = article replaced with link in the OpenGraph class?

og:type - The type of your object, e.g., "video.movie". Depending on the type you specify, other properties may also be required.

Source: The Open Graph protocol - http://ogp.me/


So If I'm checking the og:type, and it says video, then I'll naturally want to check all the video:* properties, similarly also for image. But for article, why is it replaced with link? How do I know this is an article and therefore want to parse the article:* properties?

About 3% of the time link is returned, it's actually an article, so why I'm I parsing the other 97% for no reason, when I'm only interested in articles?

oscarotero commented 7 years ago

The type returned by Embed may not be the type returned by opengraph. This is a decision made for simplicity. If there's no embed code, it's considered as a link (no mather if the link is an article, a new, event, etc). If there's embed code, it can return a video, photo and, if it's none of them, rich.

If you want to get the exact value returned by opengraph, just use the opengraph provider:

$oembed = $info->getProviders()['opengraph'];
$type = $opengraph->bag->get('type');
JanPetterMG commented 7 years ago

Conclusion: The opengraph provider is mainly made for internal Embed usage only. Anyone looking for a native provider, should use the html provider only!