Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image option in page blueprint fails when set to plain query string #6797

Open
rasteiner opened this issue Nov 15, 2024 · 0 comments
Open

Image option in page blueprint fails when set to plain query string #6797

rasteiner opened this issue Nov 15, 2024 · 0 comments

Comments

@rasteiner
Copy link
Contributor

Description

Setting the image option of a page blueprint to a query string throws a 500 error in the panel when trying to show the page in a pages section.

Expected behavior
It should be possible to set the image option of a page blueprint to a string, as documented here:
https://getkirby.com/docs/reference/panel/blueprints/page#image-options

To reproduce

  1. Install plainkit
  2. Edit site/blueprints/pages/default.yml to include an image option:
    image: page.image
  3. Install and enter into panel
  4. See error

Your setup

Kirby Version: 4.4.1 (don't think it's a "recent" regression though).

Console output

{
    "status": "error",
    "message": "array_merge(): Argument #3 must be of type array, string given",
    "code": 500,
    "exception": "TypeError",
    "key": null,
    "file": "\/kirby\/src\/Panel\/Model.php",
    "line": 134,
    "details": [],
    "route": "pages\/([a-zA-Z0-9\\.\\-_%= \\+\\@\\(\\)]+)\/sections\/([a-zA-Z0-9\\.\\-_%= \\+\\@\\(\\)]+)"
}

Fix

I think the $blueprint variable here:

kirby/src/Panel/Model.php

Lines 108 to 125 in eb47158

$blueprint = $this->model->blueprint()->image();
if ($blueprint === false) {
if (empty($settings) === true) {
return null;
}
$blueprint = null;
}
// 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
$settings = ['query' => $settings];
}

Needs the same treatment as the $settings variable: transform it into an array when it's a string different from "icon".

Workaround

Pass an array to the image option:

image:
  query: page.image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant