function picture_get_mapping_breakpoints in Picture 7.2
Same name and namespace in other branches
- 7 picture.module \picture_get_mapping_breakpoints()
Returns a list with the image styles of a mapping configuration.
Parameters
object $picture_mapping: The mapping configuration.
string $fallback_image_style: Reference to access the evaluated fallback image style.
Return value
array List with the image styles of a mapping configuration. The array has following structure: array( breakpoint_name => array( multiplier => array( mapping_type => _none|sizes|image_style, image_style => image_style_name, sizes => '(min-width: 700px) 700px, 100vw', sizes_image_styles => array( thumbnail => thumbnail, medium => medium, large => large, ), ), ), );
4 calls to picture_get_mapping_breakpoints()
- picture_field_formatter_picture_view in ./
picture.module - Helper function.
- picture_file_formatter_picture_view in ./
picture.file_entity_1.inc - View callback for hook_file_formatter_info().
- template_preprocess_flexslider_picture_list in flexslider_picture/
theme/ flexslider_picture.theme.inc - Process the items and prepare the item slides to be rendered.
- _picture_filter_prepare_image in ./
picture.module - Prepares a Render Array for theme_picture_formatter().
File
- ./
picture.module, line 2224 - Picture formatter.
Code
function picture_get_mapping_breakpoints(PictureMapping $picture_mapping, &$fallback_image_style = NULL) {
$breakpoint_styles = array();
$image_styles = array();
foreach ($picture_mapping
->getMappings() as $breakpoint_name => $multipliers) {
// Make sure there are multipliers.
if (!empty($multipliers)) {
$breakpoint = breakpoints_breakpoint_load_by_fullkey($breakpoint_name);
if ($breakpoint && $breakpoint->status) {
// Determine the enabled multipliers.
$multipliers = array_intersect_key($multipliers, $breakpoint->multipliers);
foreach ($multipliers as $multiplier => $mapping_definition) {
// Make sure the multiplier still exists.
if (!PictureMapping::isEmptyMappingDefinition($mapping_definition)) {
if ($mapping_definition['mapping_type'] == 'image_style') {
$image_styles[] = $mapping_definition['image_style'];
}
elseif ($mapping_definition['mapping_type'] == 'sizes') {
$mapping_definition['sizes_image_styles'] = array_filter($mapping_definition['sizes_image_styles']);
$image_styles = array_merge($image_styles, $mapping_definition['sizes_image_styles']);
}
if (!isset($breakpoint_styles[$breakpoint_name])) {
$breakpoint_styles[$breakpoint_name] = array();
}
$breakpoint_styles[$breakpoint_name][$multiplier] = $mapping_definition;
}
}
}
}
}
// Check if the user defined a custom fallback image style.
if (!$fallback_image_style) {
$fallback_image_style = end($image_styles);
}
return $breakpoint_styles;
}