inline_responsive_image.module in Inline responsive images 7
File
inline_responsive_image.module
View source
<?php
function inline_responsive_image_theme() {
return array(
'inline_responsive_image' => array(
'variables' => array(
'image' => '',
'attributes' => array(),
'caption' => '',
),
),
);
}
function inline_responsive_image_form_editor_image_dialog_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
$image_element = $form_state
->get('image_element') ?: [];
$responsive_image_styles = entity_load_multiple('responsive_image_style');
$image_styles = entity_load_multiple('image_style');
foreach ($responsive_image_styles as $key => $style) {
$styles[$key] = '[responsive]' . $style
->label();
}
foreach ($image_styles as $key => $style) {
$styles[$key] = $style
->label();
}
$form['style'] = array(
'#type' => 'select',
'#title' => t('Style'),
'#options' => $styles,
'#empty_value' => '',
'#default_value' => !empty($image_element['data-style']) ? $image_element['data-style'] : '',
'#parents' => array(
'attributes',
'data-style',
),
);
}