Wrap Colorbox only images with class colorbox-inline

Created on 7 July 2023, 12 months ago
Updated 28 July 2023, 11 months ago

Module wrap in colorbox ALL images (exception <img class="noColorbox"). It's bad (there no in description)
Proposition: wrap Colorbox images only with <img class="colorbox-inline"

  public function process($text, $langcode) {
    $dom = Html::load($text);

    $elements = $dom->getElementsByTagName('img');
    if ($elements->length === 0) {
      return new FilterProcessResult(Html::serialize($dom));
    }

    foreach ($elements as $element) {
      if (//!$element->hasAttribute('class') || (\strpos($element->getAttribute('class'), 'noColorbox') === FALSE)
          ($class = $element->getAttribute('class')) && in_array('colorbox-inline', explode(' ', $class) )
      	) {
        $a = $dom->createElement('a');

✨ Feature request
Status

Closed: works as designed

Version

1.1

Component

Code

Created by

🇮🇱Israel Promo-IL

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024