diff --git a/src/Plugin/EntityBrowser/Widget/PexelsWidget.php b/src/Plugin/EntityBrowser/Widget/PexelsWidget.php index e4a4735..caa692b 100644 --- a/src/Plugin/EntityBrowser/Widget/PexelsWidget.php +++ b/src/Plugin/EntityBrowser/Widget/PexelsWidget.php @@ -465,15 +465,22 @@ class PexelsWidget extends WidgetBase { ]; } + $quota['credit'] = $this->t('Photos provided by Pexels.', [ + ':link' => 'https://pexels.com', + ]); + + if (isset($results['headers']['X-Ratelimit-Remaining']) && isset($results['headers']['X-Ratelimit-Limit'])) { + $quota['quota'] = $this->t('Monthly quota @hused of @havail.', [ + '@hused' => $results['headers']['X-Ratelimit-Remaining'][0], + '@havail' => $results['headers']['X-Ratelimit-Limit'][0], + ]); + } + $form['results']['quota'] = [ '#type' => 'html_tag', '#tag' => 'small', '#attributes' => ['class' => ['media-pexels-quota']], - '#value' => $this->t('Photos provided by Pexels. / Monthly quota @hused of @havail.', [ - ':link' => 'https://pexels.com', - '@hused' => $results['headers']['X-Ratelimit-Remaining'][0], - '@havail' => $results['headers']['X-Ratelimit-Limit'][0], - ]), + '#value' => implode(' / ', $quota), ]; }