Skip to content

Commit 4311b08

Browse files
committed
set correct query in og image field, closes #31
1 parent 39eb208 commit 4311b08

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

blueprints/fields/og-image.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22

3-
use Kirby\Cms\App;
3+
use Kirby\Toolkit\Str;
44

5-
return function () {
5+
return function ($app) {
66
$blueprint = [
77
'type' => 'files',
88
'multiple' => false,
9+
'uploads' => [],
10+
'query' => Str::contains($app->path(), 'site') ? "site.images" : "page.images" // small hack to get context for field using api path
911
];
1012

1113
if ($parent = option('tobimori.seo.files.parent')) {
@@ -21,10 +23,6 @@
2123
'template' => $template
2224
];
2325

24-
if (!isset($blueprint['query'])) {
25-
$blueprint['query'] = "page.images";
26-
}
27-
2826
$blueprint['query'] = "{$blueprint['query']}.filterBy('template', '{$template}')";
2927
}
3028

0 commit comments

Comments
 (0)