You are here

function oembed_alt_attr in oEmbed 8

Same name and namespace in other branches
  1. 7 oembed.module \oembed_alt_attr()
  2. 7.0 oembed.module \oembed_alt_attr()

Generate a string for use as ALT attribute.

6 calls to oembed_alt_attr()
OembedEndpointTestCase::testOembedEndpoint in modules/oembedprovider/oembedprovider.test
OembedProviderTestCase::testOembedProviders in modules/oembedprovider/oembedprovider.test
oEmbedThumbnail::oembed_pre_render_image_helper in src/Element/oEmbedThumbnail.php
oembed_file_presave in ./oembed.file.inc
Implements hook_file_presave().
theme_oembed in theme/oembed.theme.inc
Theme for oEmbed output.

... See full list

File

./oembed.module, line 148
Core functionality for oEmbed

Code

function oembed_alt_attr(\Bangpound\oEmbed\Response\Response $embed) {
  $options = array(
    '@type' => $embed
      ->getType(),
  );

  // alt attribute using hopefully available title and provider name.
  if (!empty($embed
    ->getTitle())) {
    $string = '@title';
    $options['@title'] = $embed
      ->getTitle();
  }
  else {
    $string = 'Embedded @type';
  }
  if (!empty($embed
    ->getProviderName())) {
    $string .= ' on @provider_name';
    $options['@provider_name'] = $embed
      ->getProviderName();
  }
  return t($string, $options);
}