Embed
Embed copied to clipboard
Provider Name wrongly capitalised for many websites
$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.
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.
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...
You can replace any detector, like this one with other with a different behavior. See this example: https://github.com/oscarotero/Embed#detectors