Skip to content

Commit

Permalink
Fix YouTube oEmbed missing title accessibility issue
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Valchev authored and bobdenotter committed Jan 23, 2021
1 parent fa69955 commit 3fc0b2b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Controller/Backend/Async/EmbedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@ public function fetchEmbed(): JsonResponse
$info = EmbedFactory::create($url);
$oembed = $info->getProviders()['oembed'];

return new JsonResponse(
$oembed->getBag()->getAll()
);
$response = $oembed->getBag()->getAll();

if ($oembed->getProviderName() === 'YouTube') {
$html = $oembed->getCode();

if (! preg_match('/title=([^\s]+)/', $html)) {
$response['html'] = preg_replace('/>/', sprintf(' title="%s">', $oembed->getTitle()), $html, 1);
}
}

return new JsonResponse($response);
} catch (InvalidUrlException $e) {
return new JsonResponse([
'error' => [
Expand Down

0 comments on commit 3fc0b2b

Please sign in to comment.