Skip to content

Feat/52353 : Transcription for Remote Video#776

Open
SalahE-Ghannouch wants to merge 8 commits into3.xfrom
feat/52353
Open

Feat/52353 : Transcription for Remote Video#776
SalahE-Ghannouch wants to merge 8 commits into3.xfrom
feat/52353

Conversation

@SalahE-Ghannouch
Copy link
Collaborator

No description provided.

* )
*/
class TruncatedTextFormatter extends FormatterBase {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configurable Character Limit:

public static function defaultSettings() {
  return [
    'character_limit' => 50,
  ] + parent::defaultSettings();
}


foreach ($items as $delta => $item) {
// Limit the text to 50 characters.
$text = mb_substr($item->value, 0, 50);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Utility%21Unicode.php/function/Unicode%3A%3Atruncate/8.9.x

something like

$limit = $this->getSetting('character_limit');
for() {
Unicode::truncate($item->value, $limit, TRUE, TRUE);
}

}

$elements[$delta] = [
'#markup' => $text,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanitize for xss

'#markup' => htmlspecialchars($text, ENT_QUOTES, 'UTF-8'),

return $elements;
}

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add

public function settingsSummary() {
    return [
      $this->t('Character limit: @limit', ['@limit' => $this->getSetting('character_limit')]),
    ];
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments