Skip to content

Commit

Permalink
feat: add config to ensure full stop in alt text
Browse files Browse the repository at this point in the history
  • Loading branch information
simonerd committed May 24, 2023
1 parent 4487a27 commit 8652b7a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
12 changes: 12 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,16 @@

'lazyloading' => true,

/*
|--------------------------------------------------------------------------
| Full stop in alt tags
|--------------------------------------------------------------------------
|
| Setting this to true ensures that the alt text always ends with a
| full stop.
|
*/

'alt_fullstop' => false,

];
9 changes: 8 additions & 1 deletion src/Picturesque.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Statamic\Tags\Context;
use Statamic\Tags\Glide;
use Statamic\Tags\Parameters;
use Stringy\StaticStringy as Stringy;

class Picturesque
{
Expand Down Expand Up @@ -200,7 +201,13 @@ private function makeAlt(): string
{
if (($alt = $this->options->get('alt')) ||
($alt = $this->asset->data()->get('alt'))) {
return strip_tags($alt);
$alt = strip_tags($alt);

if (config('picturesque.alt_fullstop')) {
$alt = Stringy::ensureRight($alt, '.');
}

return $alt;
}

return '';
Expand Down

0 comments on commit 8652b7a

Please sign in to comment.