diff --git a/assets/scss/modules/editor/fields/_pre_postfix.scss b/assets/scss/modules/editor/fields/_pre_postfix.scss new file mode 100644 index 00000000..4f7bbc52 --- /dev/null +++ b/assets/scss/modules/editor/fields/_pre_postfix.scss @@ -0,0 +1,7 @@ +.form--helper { + font-size: 0.95rem; + color: #666; + max-width: 46em; + display: inline-block; + margin: 0.5rem 0; +} \ No newline at end of file diff --git a/assets/scss/modules/editor/fields/fields.scss b/assets/scss/modules/editor/fields/fields.scss index 6230cda6..e55d11f0 100644 --- a/assets/scss/modules/editor/fields/fields.scss +++ b/assets/scss/modules/editor/fields/fields.scss @@ -4,3 +4,4 @@ @import '_textarea'; @import '_date'; @import '_image'; +@import '_pre_postfix'; diff --git a/config/bolt/config.yaml b/config/bolt/config.yaml index 10afee8c..67a6fa51 100644 --- a/config/bolt/config.yaml +++ b/config/bolt/config.yaml @@ -31,7 +31,7 @@ theme: skeleton # # This can be done as [nl_NL, Dutch_Netherlands] when specifying multiple # locales, ensure the first is a standard locale. -locale: nl_NL +locale: en # Set the timezone to be used on the website. For a list of valid timezone # settings, see: http://php.net/manual/en/timezones.php diff --git a/src/Command/SetupCommand.php b/src/Command/SetupCommand.php index 7946d910..55d14b0d 100644 --- a/src/Command/SetupCommand.php +++ b/src/Command/SetupCommand.php @@ -8,6 +8,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; class SetupCommand extends Command { @@ -20,21 +21,32 @@ class SetupCommand extends Command protected function execute(InputInterface $input, OutputInterface $output): ?int { + $exitCode = 0; + $io = new SymfonyStyle($input, $output); + $command = $this->getApplication()->find('doctrine:database:create'); $commandInput = new ArrayInput(['-q' => true]); - $command->run($commandInput, $output); + $exitCode += $command->run($commandInput, $output); $command = $this->getApplication()->find('doctrine:schema:create'); $commandInput = new ArrayInput([]); - $command->run($commandInput, $output); + $exitCode += $command->run($commandInput, $output); $command = $this->getApplication()->find('bolt:add-user'); $commandInput = new ArrayInput(['--admin' => true]); - $command->run($commandInput, $output); + $exitCode += $command->run($commandInput, $output); $command = $this->getApplication()->find('doctrine:fixtures:load'); $commandInput = new ArrayInput(['--append' => true]); - $command->run($commandInput, $output); + $exitCode += $command->run($commandInput, $output); + + $io->newLine(); + + if ($exitCode !== 0) { + $io->error('Some errors occurred while setting up Bolt.'); + } else { + $io->success('Bolt was set up successfully! Start a web server, and open your Bolt site in a browser.'); + } return null; } diff --git a/src/Twig/ImageExtension.php b/src/Twig/ImageExtension.php index 3820b28b..30da232d 100644 --- a/src/Twig/ImageExtension.php +++ b/src/Twig/ImageExtension.php @@ -131,12 +131,16 @@ class ImageExtension extends AbstractExtension } /** - * @param ImageField|array|string $image + * @param ImageField|Content|array|string $image */ private function getFilename($image): ?string { $filename = null; + if ($image instanceof Content) { + $image = $this->getImageFromContent($image); + } + if ($image instanceof ImageField) { $filename = $image->get('filename'); } elseif (is_array($image)) { @@ -149,12 +153,16 @@ class ImageExtension extends AbstractExtension } /** - * @param ImageField|array|string $image + * @param ImageField|Content|array|string $image */ private function getAlt($image): string { $alt = ''; + if ($image instanceof Content) { + $image = $this->getImageFromContent($image); + } + if ($image instanceof ImageField) { $alt = $image->get('alt'); } elseif (is_array($image)) { @@ -165,4 +173,15 @@ class ImageExtension extends AbstractExtension return htmlentities($alt, ENT_QUOTES); } + + private function getImageFromContent(Content $content): ?ImageField + { + foreach ($content->getFields() as $field) { + if ($field instanceof ImageField) { + return $field; + } + } + + return null; + } } diff --git a/templates/media/edit.html.twig b/templates/media/edit.html.twig index 0bdd59a8..731fbce9 100644 --- a/templates/media/edit.html.twig +++ b/templates/media/edit.html.twig @@ -73,13 +73,14 @@