public function BlazyAdminBase::breakpointElements in Blazy 8
Same name and namespace in other branches
- 7 src/Form/BlazyAdminBase.php \Drupal\blazy\Form\BlazyAdminBase::breakpointElements()
Defines re-usable breakpoints form.
1 call to BlazyAdminBase::breakpointElements()
- BlazyAdminBase::breakpointsForm in src/
Form/ BlazyAdminBase.php - Defines re-usable breakpoints form.
File
- src/
Form/ BlazyAdminBase.php, line 260
Class
- BlazyAdminBase
- A base for blazy admin integration to have re-usable methods in one place.
Namespace
Drupal\blazy\FormCode
public function breakpointElements($definition = []) {
foreach ($definition['breakpoints'] as $breakpoint) {
$form[$breakpoint]['breakpoint'] = [
'#type' => 'item',
'#markup' => $breakpoint,
'#weight' => 1,
'#wrapper_attributes' => [
'class' => [
'form-item--right',
],
],
];
$form[$breakpoint]['image_style'] = [
'#type' => 'select',
'#title' => $this
->t('Image style'),
'#title_display' => 'invisible',
'#options' => function_exists('image_style_options') ? image_style_options(FALSE) : [],
'#empty_option' => $this
->t('- None -'),
'#weight' => 2,
'#wrapper_attributes' => [
'class' => [
'form-item--left',
],
],
];
$form[$breakpoint]['width'] = [
'#type' => 'textfield',
'#title' => $this
->t('Width'),
'#title_display' => 'invisible',
'#description' => $this
->t('See <strong>XS</strong> for detailed info.'),
'#maz_length' => 32,
'#size' => 6,
'#weight' => 3,
'#attributes' => [
'class' => [
'form-text--width',
'js-expandable',
],
],
'#wrapper_attributes' => [
'class' => [
'form-item--width',
],
],
];
if ($breakpoint == 'xs') {
$form[$breakpoint]['width']['#description'] = $this
->t('E.g.: <strong>640</strong>, or <strong>2x</strong>, or for <strong>small devices</strong> may be combined into <strong>640w 2x</strong> where <strong>x (pixel density)</strong> descriptor is used to define the device-pixel ratio, and <strong>w (width)</strong> descriptor is the width of image source and works in tandem with <strong>sizes</strong> attributes. Use <strong>w (width)</strong> if any issue/ unsure. Default to <strong>w</strong> if no descriptor provided for backward compatibility.');
}
}
return $form;
}