Skip to content

Commit

Permalink
Merge pull request #470 from helsingborg-stad/3.0/fix/script-error-no…
Browse files Browse the repository at this point in the history
…tices

Fix: Script error notices
  • Loading branch information
Anna authored Sep 8, 2023
2 parents f1796f2 + 6500b4c commit 2e2e057
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
18 changes: 10 additions & 8 deletions source/php/Module/Script/Script.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ public function data() : array
$data['scriptWrapWithClassName'] = get_field('script_wrap_with', $this->ID) ?? 'card';

$placeholder = get_field('embedded_placeholder_image', $this->ID);
$attachment = wp_get_attachment_image_src($placeholder['ID'], [1000, false]);

$data['placeholder'] = [
'url' => $attachment[0],
'width' => $attachment[1],
'height' => $attachment[2],
'alt' => $placeholder['alt']
];
$attachment = !empty($placeholder) ?
wp_get_attachment_image_src($placeholder['ID'], [1000, false]) : false;
if (!empty($attachment)) {
$data['placeholder'] = [
'url' => $attachment[0],
'width' => $attachment[1],
'height' => $attachment[2],
'alt' => $placeholder['alt']
];
}

$embededCardPadding = get_field('embeded_card_padding', $this->ID);
$data['scriptPadding'] =
Expand Down
15 changes: 8 additions & 7 deletions source/php/Module/Script/views/card.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
@endif

@include('partials.content')

@image([
'src' => $placeholder['url'],
'alt' => $placeholder['alt'],
'classList' => ['box-image', 'u-print-display--inline-block', 'u-display--none']
])
@endimage
@if(!empty($placeholder['url']))
@image([
'src' => $placeholder['url'],
'alt' => $placeholder['alt'],
'classList' => ['box-image', 'u-print-display--inline-block', 'u-display--none']
])
@endimage
@endif
@endcard

0 comments on commit 2e2e057

Please sign in to comment.