I added an “Insert Image” button to the textarea button panel to ease inserting images with the (image: filename) syntax. It works like a charme if you define a select field for the image and populate the options with the query method. It does not work, however, if you use the Kirby core image field with thumbnail preview.
The error message is the following:
Fatal error: Method ImageField::__toString() must not throw an exception, caught Error: Call to a member function image() on null in [...]\kirby\toolkit\lib\brick.php on line 0
The actual call to the member function happens at \panel\app\fields\image\image.php::20.
As far as I tracked it down, $this->page is not set, but I cannot figure out, where it is set for image fields in the edit page view.
Does anyone know another way to use image fields in modals, when calling them from a textarea button?
The issue is that the panel fields get their page model from a method invoked by the blueprint class. That is obviously not called, when your field is not instanciated as a blueprint field. You simply have to set the page attribute yourself, when you define your image field in the form: