protected function AmpPrepareMetadataJson::prepareDescription in Accelerated Mobile Pages (AMP) 8
Prepare description of content, if available: maximum 150 characters.
1 call to AmpPrepareMetadataJson::prepareDescription()
- AmpPrepareMetadataJson::prepareMetadataJson in src/
Utility/ AmpPrepareMetadataJson.php - Prepares a metadata array to be ready for JSON conversion.
File
- src/
Utility/ AmpPrepareMetadataJson.php, line 241
Class
- AmpPrepareMetadataJson
- Class AmpPrepareMetadataJson
Namespace
Drupal\amp\UtilityCode
protected function prepareDescription() {
if (isset($this->ampMetadataSettings['content_description_token']) && !empty($this->ampMetadataSettings['content_description_token'])) {
$description = PlainTextOutput::renderFromHtml($this->token
->replace($this->ampMetadataSettings['content_description_token'], [
'node' => $this->node,
]));
$this->ampPreparedMetadataJson['description'] = strlen($description) > 150 ? mb_strimwidth($description, 0, 147, "...") : $description;
}
}