Oh caption, my caption |
Specifications
Based on the specific imagestyle or specific picture mapping, decide to render or not render a caption. The content of the caption is the content of the title attribute.
Solution
Add a theme function to your theme's template.php
The idea is to simply override the theming function in picture (which is the module I use for my responsive images)
// this theming function assumes that the picture module is installed
function THEMENAME_picture($variables) {
// first produce the standard picture output
$output=theme_picture($variables);
// we only add titles to the images where a specific picture mapping is defined
if (array_key_exists('breakpoints', $variables) && array_key_exists('title', $variables)){
if ($variables[breakpoints]['custom.user.normal']['1x'][image_style] =='rsp_adviesplaatjecustom_user_normal_1x'){
if ($variables['title'] !=''){
$output=$output.'<div class="image-caption"><div class="image-caption-text">'.$variables['title'].'</div></div>';
}
}
}
return $output;
}
No comments:
Post a Comment