Embed icon indicating copy to clipboard operation
Embed copied to clipboard

Provider Name wrongly capitalised for many websites

Open diogogithub opened this issue 3 years ago • 3 comments

$embed                     = new LibEmbed();
$info                      = $embed->get($url);
$metadata['title']         = $info->title;
$metadata['description']   = $info->description;
$metadata['author_name']   = $info->authorName;
$metadata['author_url']    = (string) $info->authorUrl;
$metadata['provider_name'] = $info->providerName;
$root_url                  = parse_url($url);
$root_url                  = "{$root_url['scheme']}://{$root_url['host']}";
$metadata['provider_url']  = (string) ($info->providerUrl != '' ? $info->providerUrl : $root_url);

With $url = 'https://eportugal.gov.pt/' the providerName is set as Eportugal instead of ePortugal. Even though "Eportugal" is not present anywhere in the website. On the other hand, YouTube is returned as "YouTube". For many other websites it seems that the pattern of capitalising only the first letter and having the rest lower case is present.

diogogithub avatar Dec 02 '21 21:12 diogogithub

The capitalised domain name is the fallback when the provider name is not found in the code. You can see here the ProviderName detector code: https://github.com/oscarotero/Embed/blob/master/src/Detectors/ProviderName.php#L15

  • It search it in the provider_name key of oEmbed (if exists)
  • If not, searcht the og:site_name, publisher, etc meta tags
  • And if it's found, return the fallback.

oscarotero avatar Dec 03 '21 09:12 oscarotero

Oh... Is there any setting to set the fallback to something like null representing the absence of value? Otherwise it can be complicated to distinguish between actual findings and this fallback...

diogogithub avatar Dec 18 '21 14:12 diogogithub

You can replace any detector, like this one with other with a different behavior. See this example: https://github.com/oscarotero/Embed#detectors

oscarotero avatar Dec 20 '21 16:12 oscarotero