function picture_ckeditor_css in Picture 7.2
Generate css to handle more realistic display of image styles.
1 call to picture_ckeditor_css()
- picture_page_build in ./
picture.module - Implements hook_page_build().
File
- ./
picture.module, line 1973 - Picture formatter.
Code
function picture_ckeditor_css($prefix = '') {
$image_styles = image_styles();
$picture_mappings = picture_mapping_load_all();
$ckeditor_mappings = variable_get('picture_ckeditor_mappings', array());
$mappings = array();
foreach ($ckeditor_mappings as $machine_name => $parameters) {
if (!array_key_exists($machine_name, $picture_mappings)) {
continue;
}
if ($parameters['enabled'] != 1) {
continue;
}
if (array_key_exists($parameters['fallback'], $image_styles)) {
$dimensions = array(
'width' => 1000,
'height' => 1000,
);
// Transform dimensions.
image_style_transform_dimensions($parameters['fallback'], $dimensions);
// Add unit if needed.
if (strpos($dimensions['width'], '%') === FALSE) {
$dimensions['width'] .= 'px';
}
if (strpos($dimensions['height'], '%') === FALSE) {
$dimensions['height'] .= 'px';
}
$mappings[$machine_name] = $prefix . ' [data-picture-mapping="' . $machine_name . '"] {';
$mappings[$machine_name] .= ' width: ' . $dimensions['width'] . ';';
$mappings[$machine_name] .= ' height: ' . $dimensions['height'] . ';';
$mappings[$machine_name] .= '}';
}
}
return implode("\n", $mappings);
}