Skip to content

Commit

Permalink
Merge pull request #6916 from getkirby/fix/6797-model-image-query-string
Browse files Browse the repository at this point in the history
Fix `image` with query string in blueprint
  • Loading branch information
distantnative authored Jan 17, 2025
2 parents 2c2e9d1 + b2d8fd5 commit 78b2784
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Panel/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,19 @@ public function image(
$blueprint = null;
}

// convert string blueprint settings to proper array
if (is_string($blueprint) === true) {
$blueprint = ['query' => $blueprint];
}

// skip image thumbnail if option
// is explicitly set to show the icon
if ($settings === 'icon') {
$settings = ['query' => false];
} elseif (is_string($settings) === true) {
// convert string settings to proper array
}

// convert string settings to proper array
if (is_string($settings) === true) {
$settings = ['query' => $settings];
}

Expand Down
29 changes: 29 additions & 0 deletions tests/Panel/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,35 @@ public function testImageWithBlueprintFalse()
$this->assertNull($image);
}

/**
* @covers ::image
*/
public function testImageWithBlueprintString()
{
$app = $this->app->clone([
'blueprints' => [
'pages/fox' => [
'image' => 'site.page("test").image'
]
],
'site' => [
'children' => [
[
'slug' => 'test',
'template' => 'fox',
'files' => [
['filename' => 'test.jpg']
]
]
]
]
]);

$panel = $app->page('test')->panel();
$image = $panel->image([]);
$this->assertStringEndsWith('test.jpg', $image['url']);
}

/**
* @covers ::image
*/
Expand Down

0 comments on commit 78b2784

Please sign in to comment.