3 namespace Drupal\blazy\Form;
8 * Provides admin form specific to Blazy admin formatter.
10 class BlazyAdminFormatter extends BlazyAdminFormatterBase {
13 * Defines re-usable form elements.
15 public function buildSettingsForm(array &$form, $definition = []) {
16 $definition['namespace'] = 'blazy';
17 $definition['responsive_image'] = isset($definition['responsive_image']) ? $definition['responsive_image'] : TRUE;
19 $this->openingForm($form, $definition);
20 $this->imageStyleForm($form, $definition);
22 if (!empty($definition['media_switch_form']) && !isset($form['media_switch'])) {
23 $this->mediaSwitchForm($form, $definition);
26 if (!empty($definition['grid_form']) && !isset($form['grid'])) {
27 $this->gridForm($form, $definition);
29 // Blazy doesn't need complex grid with multiple groups.
30 unset($form['preserve_keys'], $form['visible_items']);
32 if (isset($form['grid'])) {
33 $form['grid']['#description'] = $this->t('The amount of block grid columns for large monitors 64.063em+. <br /><strong>Requires</strong>:<ol><li>Display style.</li><li>A reasonable amount of contents.</li></ol>Leave empty to DIY, or to not build grids.');
37 if (!empty($definition['breakpoints'])) {
38 $this->breakpointsForm($form, $definition);
41 if (isset($form['responsive_image_style'])) {
42 $form['responsive_image_style']['#description'] = $this->t('Not compatible with below breakpoints, aspect ratio, yet. However it can still lazyload by checking <strong>Responsive image</strong> option via Blazy UI. Leave empty to disable.');
44 if ($this->blazyManager()->getModuleHandler()->moduleExists('blazy_ui')) {
45 $form['responsive_image_style']['#description'] .= ' ' . $this->t('<a href=":url" target="_blank">Enable lazyloading Responsive image</a>.', [':url' => Url::fromRoute('blazy.settings')->toString()]);
49 $this->closingForm($form, $definition);