getImageStyleMappings example

'sizes' => '2',
          'sizes_image_styles' => [
            'custom_image_style_1',
            'custom_image_style_2',
          ],
        ],
        'breakpoint_id' => 'responsive_image.computertwo',
        'multiplier' => 'multiplier_2',
      ],
    ];
    $this->assertSame($expected_image_style_mappings, ResponsiveImageStyle::load('narrow')
      ->getImageStyleMappings());
  }

}

  }

  /** * Test order multipliers numerically upgrade path. * * @see responsive_image_post_update_order_multiplier_numerically() * * @legacy */
  public function testUpdate(): void {
    $mappings = ResponsiveImageStyle::load('responsive_image_style')->getImageStyleMappings();
    $this->assertEquals('1.5x', $mappings[0]['multiplier']);
    $this->assertEquals('2x', $mappings[1]['multiplier']);
    $this->assertEquals('1x', $mappings[2]['multiplier']);

    $this->runUpdates();

    $mappings = ResponsiveImageStyle::load('responsive_image_style')->getImageStyleMappings();
    $this->assertEquals('1x', $mappings[0]['multiplier']);
    $this->assertEquals('1.5x', $mappings[1]['multiplier']);
    $this->assertEquals('2x', $mappings[2]['multiplier']);
  }

  

  public function orderMultipliersNumerically(ResponsiveImageStyleInterface $responsive_image_style): bool {
    $changed = FALSE;

    $original_mapping_order = $responsive_image_style->getImageStyleMappings();
    $responsive_image_style->removeImageStyleMappings();
    foreach ($original_mapping_order as $mapping) {
      $responsive_image_style->addImageStyleMapping($mapping['breakpoint_id']$mapping['multiplier']$mapping);
    }
    if ($responsive_image_style->getImageStyleMappings() !== $original_mapping_order) {
      $changed = TRUE;
    }

    $deprecations_triggered = &$this->triggeredDeprecations['3267870'][$responsive_image_style->id()];
    if ($this->deprecationsEnabled && $changed && !$deprecations_triggered) {
      $deprecations_triggered = TRUE;
      @
$map = $this->getKeyedImageStyleMappings();
    if (isset($map[$breakpoint_id][$multiplier])) {
      return $map[$breakpoint_id][$multiplier];
    }
  }

  /** * {@inheritdoc} */
  public function getImageStyleIds() {
    $image_styles = [$this->getFallbackImageStyle()];
    foreach ($this->getImageStyleMappings() as $image_style_mapping) {
      // Only image styles of non-empty mappings should be loaded.       if (!$this::isEmptyImageStyleMapping($image_style_mapping)) {
        switch ($image_style_mapping['image_mapping_type']) {
          case 'image_style':
            $image_styles[] = $image_style_mapping['image_mapping'];
            break;

          case 'sizes':
            $image_styles = array_merge($image_styles$image_style_mapping['image_mapping']['sizes_image_styles']);
            break;
        }
      }
'large' => 'large',
          ],
        ],
      ],
      [
        'breakpoint_id' => 'test_breakpoint2',
        'multiplier' => '1x',
        'image_mapping_type' => 'image_style',
        'image_mapping' => 'thumbnail',
      ],
    ];
    $this->assertEquals($expected$entity->getImageStyleMappings());
  }

  /** * @covers ::addImageStyleMapping * @covers ::removeImageStyleMappings */
  public function testRemoveImageStyleMappings() {
    $entity = new ResponsiveImageStyle(['']);
    $entity->addImageStyleMapping('test_breakpoint', '1x', [
      'image_mapping_type' => 'image_style',
      'image_mapping' => 'large',
    ]);
Home | Imprint | This part of the site doesn't use cookies.