createMediaField example

/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * @covers ::viewElements * * @dataProvider dataProvider */
  public function testRender($tag_count$formatter_settings) {
    $field_config = $this->createMediaField('file_video', 'mp4', $formatter_settings);

    file_put_contents('public://file.mp4', str_repeat('t', 10));
    $file1 = File::create([
      'uri' => 'public://file.mp4',
      'filename' => 'file.mp4',
    ]);
    $file1->save();

    $file2 = File::create([
      'uri' => 'public://file.mp4',
      'filename' => 'file.mp4',
    ]);

                'attributes' => [
                    'padding' => '10',
                    'margin' => '5',
                    'layout' => 'anchor',
                    'defaults' => ['labelWidth' => 155, 'anchor' => '100%'],
                ],
            ]
        );

        $fieldSet->addElement(
            $this->createMediaField(
                'mobileLogo',
                '__smartphone__',
                'frontend/_public/src/img/logos/logo--mobile.png',
                ['attributes' => ['lessCompatible' => false]]
            )
        );

        $fieldSet->addElement(
            $this->createMediaField(
                'tabletLogo',
                '__tablet__',
                
/** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * @covers ::viewElements * * @dataProvider dataProvider */
  public function testRender($tag_count$formatter_settings) {
    $field_config = $this->createMediaField('file_audio', 'mp3', $formatter_settings);

    file_put_contents('public://file.mp3', str_repeat('t', 10));
    $file1 = File::create([
      'uri' => 'public://file.mp3',
      'filename' => 'file.mp3',
    ]);
    $file1->save();

    $file2 = File::create([
      'uri' => 'public://file.mp3',
      'filename' => 'file.mp3',
    ]);
Home | Imprint | This part of the site doesn't use cookies.