function template_preprocess_views_foundation_clearing in Views Foundation 7.4
Same name and namespace in other branches
- 7 theme/views_foundation.theme.inc \template_preprocess_views_foundation_clearing()
Theme the Foundation Orbit Clearing.
File
- theme/
views_foundation.theme.inc, line 39 - The theme system, which controls the output of views foundation plugins.
Code
function template_preprocess_views_foundation_clearing(&$variables) {
// Preprare fields for the output.
foreach ($variables['view']->style_plugin->rendered_fields as $index => $row) {
foreach ($row as $key => $value) {
if ($variables['options']['image'] == $key) {
// Get image url from img tag.
if ($value) {
$url = simplexml_import_dom(DOMDocument::loadHTML($value))
->xpath("//img/@src");
$variables['fields'][$index]['image'] = check_url(reset($url));
}
}
elseif ($variables['options']['thumbnail'] == $key) {
// Get thumbnail url from img tag.
if ($value) {
$url = simplexml_import_dom(DOMDocument::loadHTML($value))
->xpath("//img/@src");
$variables['fields'][$index]['thumbnail'] = check_url(reset($url));
}
}
elseif ($variables['options']['caption'] == $key) {
$value ? $variables['fields'][$index]['caption'] = check_plain(strip_tags($value)) : '';
}
}
if (!isset($variables['fields'][$index]['image'])) {
// Unset row if main image not found.
unset($variables['fields'][$index]);
}
elseif (!isset($variables['fields'][$index]['thumbnail'])) {
// Use main image for thumbnail if thumbnail not set.
$variables['fields'][$index]['thumbnail'] = $variables['fields'][$index]['image'];
}
}
// Add class for thumbnail border.
$variables['class']['link'] = $variables['options']['thumb_border'] ? 'th' : '';
if (variable_get('views_foundation_clearing', 1)) {
// Add Foundation Clearing JavaScript.
drupal_add_js(check_url(variable_get('views_foundation_js')) . '/foundation/foundation.clearing.js', array(
'type' => 'file',
'group' => -999,
'scope' => 'footer',
));
}
}