function text_summary
Same name and namespace in other branches
- 11.x core/modules/text/text.module \text_summary()
- 10 core/modules/text/text.module \text_summary()
- 9 core/modules/text/text.module \text_summary()
- 8.9.x core/modules/text/text.module \text_summary()
- 7.x modules/field/modules/text/text.module \text_summary()
Generates a trimmed, formatted version of a text field value.
If the end of the summary is not indicated using the <!--break--> delimiter then we generate the summary automatically, trying to end it at a sensible place such as the end of a paragraph, a line break, or the end of a sentence (in that order of preference).
Parameters
string $text: The content for which a summary will be generated.
string $format: The format of the content. If the line break filter is present then we treat newlines embedded in $text as line breaks. If the htmlcorrector filter is present, it will be run on the generated summary (if different from the incoming $text).
int|numeric-string|null $size: The desired character length of the summary. If omitted, the default value will be used. Ignored if the special delimiter is present in $text.
Return value
string The generated summary.
Deprecated
in drupal:11.4.0 and is removed from drupal:13.0.0. Use \Drupal::service(TextSummary::class)->generate() instead.
See also
https://www.drupal.org/node/3568389
File
-
core/
modules/ text/ text.module, line 36
Code
function text_summary($text, $format = NULL, $size = NULL) {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Use \\Drupal::service(TextSummary::class)->generate() instead. See https://www.drupal.org/node/3568389', E_USER_DEPRECATED);
if (!isset($size)) {
$size = \Drupal::config('text.settings')->get('default_summary_length');
}
return \Drupal::service(TextSummary::class)->generate($text, $format, (int) $size);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.