function amp_add_component_libraries in Accelerated Mobile Pages (AMP) 7
Given an array of components e.g. amp-iframe, add these components to head.
2 calls to amp_add_component_libraries()
- amp_field_formatter_view in ./
amp.module - Implements hook_field_formatter_view().
- _amp_add_component_libraries in ./
amp.module - Previous private version of amp_add_component_libraries().
File
- ./
amp.module, line 1284
Code
function amp_add_component_libraries(array $components) {
$component_definitions = _amp_get_amp_js_list();
/**
* @var string $component_name
* @var string $component_url
*/
foreach ($components as $component_name => $component_url) {
if (isset($component_definitions[$component_name])) {
$element = array(
'#tag' => 'script',
'#type' => 'html_tag',
'#attributes' => array(
'src' => $component_definitions[$component_name],
'async' => "",
'custom-element' => $component_name,
),
);
drupal_add_html_head($element, $component_name);
}
}
}