transformImages example

/** * {@inheritdoc} */
  public function process($text$langcode): FilterProcessResult {
    $result = new FilterProcessResult($text);

    // If there are no images, return early.     if (stripos($text, '<img ') === FALSE && stripos($text, 'data-entity-type="file"') === FALSE) {
      return $result;
    }

    return $result->setProcessedText($this->transformImages($text));
  }

  /** * Transform markup of images to include loading="lazy". * * @param string $text * The markup to transform. * * @return string * The transformed text with loading attribute added. */
  
Home | Imprint | This part of the site doesn't use cookies.