Same name and namespace in other branches
- 5.0.x advagg.module \advagg_css_alter() 1 commentaire
- 6.0.x advagg.module \advagg_css_alter() 1 commentaire
- 7.x-2.x advagg_font/advagg_font.module \advagg_css_alter() 1 commentaire
- 8.x-3.x advagg.module \advagg_css_alter() 1 commentaire
- 8.x-4.x advagg.module \advagg_css_alter() 1 commentaire
Implements hook_css_alter().
Fichier
-
./
advagg.module, line 235
Code
function advagg_css_alter(&$css) {
if (!advagg_enabled()) {
return;
}
if (\Drupal::config('advagg.settings')->get('css.fix_type')) {
// Fix type if it was incorrectly set.
foreach ($css as &$value) {
if (empty($value['data']) || !is_string($value['data'])) {
continue;
}
// Default to file if not set.
if ($value['type'] !== 'file' && $value['type'] !== 'external') {
$value['type'] = 'file';
}
// If type is external but doesn't start with http, https, or // change it
// to file.
if ($value['type'] === 'external' && stripos($value['data'], 'http://') !== 0 && stripos($value['data'], 'https://') !== 0 && stripos($value['data'], '//') !== 0) {
$value['type'] = 'file';
}
// If type is file but it starts with http, https, or // change it to
// external.
if ($value['type'] === 'file' && (stripos($value['data'], 'http://') === 0 || stripos($value['data'], 'https://') === 0 || stripos($value['data'], '//') === 0 && stripos($value['data'], '///') === FALSE)) {
$value['type'] = 'external';
}
}
unset($value);
}
}