You are here

function image_effects_post_update_text_overlay_maximum_chars in Image Effects 8

Add 'maximum_chars' and 'excess_chars_text' parameters to 'Text Overlay' effects.

File

./image_effects.post_update.php, line 19
Post-update functions for Image Effects.

Code

function image_effects_post_update_text_overlay_maximum_chars() {

  // @codingStandardsIgnoreEnd
  foreach (ImageStyle::loadMultiple() as $image_style) {
    $edited = FALSE;
    foreach ($image_style
      ->getEffects() as $effect) {
      if ($effect
        ->getPluginId() === "image_effects_text_overlay") {
        $configuration = $effect
          ->getConfiguration();
        $configuration['data']['text']['maximum_chars'] = NULL;
        $configuration['data']['text']['excess_chars_text'] = t('…');
        unset($configuration['data']['preview_bar']);
        $effect
          ->setConfiguration($configuration);
        $edited = TRUE;
      }
    }
    if ($edited) {
      $image_style
        ->save();
    }
  }
}