Reputation: 127
I have implemented Quill's WYSIWYG editor on my website. With that, I also wanted an image resizer, and many people recommended this component. I also installed PHP Quill Renderer to translate Quill's Delta into HTML.
I tested everything and it works fine (the data I receive from the renderer corresponds to the data I posted with the form).
However, if I resize an image in the Quill editor and send it to the renderer, I am getting this error:
Fatal error: Uncaught TypeError: Argument 1 passed to DBlackborough\Quill\Delta\Html\Insert::__construct() must be of the type string, array given, called in ...... on line 22
I checked the file and this function was on line 22:
public function __construct(string $insert, array $attributes = [])
{
$this->tag = null;
$this->insert = $insert;
$this->attributes = $attributes;
}
As a beginner to all of this, I do not know what I should do. I assume that because I am using an external component (i.e. Quill Image Resizer) which was not part of Quill js, the developer of the Php Quill Renderer did not add support for image resizing.
Can anybody guide me through the steps I should take to correct this error?
Upvotes: 1
Views: 1188
Reputation: 96
i had the same problem, here is how I corrected it
Information about the problem:
The attribute width="xx"
is inserted by Quill Image Resizer
plugin when you resize the image. However in PHP Quill Renderer
, Parse does not know this attribute, being associated with no Delta uses the default.
switch ($attribute) {
default:
$this->insert($quill);
break;
}
Solution:
To correct this problem we need to add a new width
constant in the options and then in parse we need to add a new case
to link this constant to the image.
page : Options.php (ligne : 50)
public const ATTRIBUTE_WIDTH = 'width';
public const ATTRIBUTE_ALT = 'alt';
page : Parser/Parse.php (ligne : 179)
case Options::ATTRIBUTE_WIDTH:
$this->image($quill);
break;
case Options::ATTRIBUTE_ALT:
$this->image($quill);
break;
Not sure this is the best solution, but it fixes the problem and no change is to be made to the basic functions. As you can see in my code I also add the alt
attribute to associate it with the image. It may be as profitable for you
Good luck !
Upvotes: 1