Skip to content

Commit

Permalink
Merge pull request #4 from mitydigital/feature/2025-jan-updates
Browse files Browse the repository at this point in the history
January 2025 updates
  • Loading branch information
martyf authored Jan 14, 2025
2 parents c9f782d + 2faa12a commit 2327e02
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 54 deletions.
20 changes: 0 additions & 20 deletions resources/fieldsets/metadata_social.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,6 @@ fields:
display: 'Social image'
icon: assets
instructions: "The entry-specific Social image. This overrides the site's default Social image. The recommended size is 1200x630px. This image will be focal cropped to this dimension."
width: 50
listable: hidden
instructions_position: below
visibility: visible
hide_display: false
-
handle: twitter_image
field:
max_files: 1
mode: list
container: site
restrict: false
allow_uploads: true
show_filename: true
show_set_alt: true
type: assets
display: 'Twitter image'
icon: assets
instructions: "The entry-specific Twitter image. This overrides the site's default Twitter image. Images should have an aspect ratio of 2:1 with minimum dimensions of 300x157. This image will be focal cropped to this dimension."
width: 50
listable: hidden
instructions_position: below
visibility: visible
Expand Down
16 changes: 14 additions & 2 deletions src/Tags/Concerns/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Statamic\Facades\Antlers;
use Statamic\Facades\GlobalSet;
use Statamic\Facades\Site;
use Statamic\Fieldtypes\Bard;
use Statamic\Fieldtypes\Bard\Augmentor;

trait Form
{
Expand Down Expand Up @@ -128,11 +130,21 @@ public function getFormLang()

// get the override
foreach ($global->get('message_overrides', []) as $override) {
if ($override['form'] === $form && $override['type'] === $type) {
if ($override['form'] === $form->handle() && $override['type'] === $type) {
$message = $override['message'];
}
}

return Antlers::parse($message)->__toString();
if (is_array($message)) {
$bard = (new Bard())->setField($global->blueprint()->field($fieldHandle));

$content = (new Augmentor($bard))
->augment($message);

return $content;
} else {

return Antlers::parse($message)->__toString();
}
}
}
1 change: 1 addition & 0 deletions src/Tags/Concerns/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public function image()
2000,
2400,
3000,
3600,
];

$srcset = [];
Expand Down
35 changes: 3 additions & 32 deletions src/Tags/Concerns/Scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,9 @@ protected function scriptsLoad($location)
) {
// only process the scripts for the given location
return collect($metadata->get('javascript', []))
->filter(fn ($javascript) => $javascript['location'] === $location && $javascript['enabled'])
->map(function ($javascript) {
if ($javascript['type'] === 'script_tag') {
// make a script tag
$script = '<script';

if ($javascript['asynchronous']) {
$script .= ' async';
}

if ($javascript['defer']) {
$script .= ' defer';
}

if (isset($javascript['additional_attributes']) && $javascript['additional_attributes']) {
$script .= ' ' . $javascript['additional_attributes'];
}

$script .= ' src="'.$javascript['src'].'"></script>';

return $script;
}

if ($javascript['type'] === 'inline_script') {
// output the included javascript inline
$script = '<script type="text/javascript">'."\r\n";
$script .= $javascript['script']['code'];
$script .= "\r\n".'</script>';

return $script;
}
})->join("\r\n");
->filter(fn (array $javascript) => $javascript['location'] === $location && $javascript['enabled'])
->map(fn (array $javascript) => $javascript['script'])
->join("\r\n");
}
}
}

0 comments on commit 2327e02

Please sign in to comment.