imageAttributes example

$this->drupalLogin($this->adminUser);
  }

  /** * Tests the Drupal image URL widget. */
  public function testImageUrlWidget(): void {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

    $image_selector = '.ck-widget.image-inline';
    $src = $this->imageAttributes()['src'];

    $this->drupalGet($this->host->toUrl('edit-form'));
    $this->waitForEditor();

    $this->pressEditorButton('Insert image');
    $panel = $page->find('css', '.ck-dropdown__panel.ck-image-insert__panel');
    $src_input = $panel->find('css', 'input[type=text]');
    $src_input->setValue($src);
    $panel->find('xpath', "//button[span[text()='Insert']]")->click();

    $this->assertNotEmpty($assert_session->waitForElementVisible('css', $image_selector));
    
/** * Helper to format attributes. * * @param bool $reverse * Reverse attributes when printing them. * * @return string */
  protected function imageAttributesAsString($reverse = FALSE) {
    $string = [];
    foreach ($this->imageAttributes() as $key => $value) {
      $string[] = $key . '="' . $value . '"';
    }
    if ($reverse) {
      $string = array_reverse($string);
    }
    return implode(' ', $string);
  }

  /** * Add an image to the CKEditor 5 editable zone. */
  
Home | Imprint | This part of the site doesn't use cookies.