Forum


Replies: 6   Views: 1514
Insert image stream with embedhtml
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by hotspot22  · 22-07-2020 - 12:38

Hi,

I have a problem with inserting image streams into my docx when using url get parameter.

The following with direct url to image file is working correctly:

$docx = new CreateDocx();
$html = '<img src="https://www.mydomain.com/images/test.png">';
$docx->embedHTML($html);

Also this block with referencing a php file is working fine:

$docx = new CreateDocx();
$html = '<img src="https://www.mydomain.com/image.php">';
$docx->embedHTML($html);

In my test example the content of my image.php is:

<?php
echo file_get_contents('/images/test.png');

But now my problem comes with this code:

$docx = new CreateDocx();
$html = '<img src="https://www.mydomain.com/image.php?id=123">'; // adding ?id=123
$docx->embedHTML($html);

My image.php is not changed and should output my test image.

I've only added the get parameter id=123 to the url and with this change, the image is no longer shown in the document. Instead there is only a border with a red cross in the upper left corner and an error message saying that the image can't be displayed.

?????? Any suggestions?

 

Posted by hotspot22  · 23-07-2020 - 05:20

It's 9.5 Premium.

Adding a questionmark to the end of the image url causes the image not beeing displayed in the docx.

Using a RewriteRule ^image/(.*)$ image.php?id=$1 to insert my image by ...

$docx = new CreateDocx();
$html = '<img src="https://www.mydomain.com/image/123">';
$docx->embedHTML($html);

... is also working.

That's confusing...

Posted by admin  · 23-07-2020 - 08:43

Hello,

phpdcx parses the URL to be able to get the image type, using exif_imagetype when no extension is found as it's the case of stream images.

We have run the internal tests and all cases return the correct output. Although using a URL such as /image/123 is a good alternative, if you are using a public URL, please send it to contact[at]phpdocx.com and we'll test it. We have also moved the topic to the dev team to do more tests.

Regards.

Posted by hotspot22  · 23-07-2020 - 09:42

Running exif_imagetype for the url with parameters returns 3 which stands for IMAGETYPE_PNG and this is correct.

Sent you an email with the concrete url.

Posted by skilltran  · 28-08-2020 - 21:59

I'm having the exact same issue, adding a image using query strings won't display on generated file docx. Any update on this would be helpfull.

 

Posted by admin  · 29-08-2020 - 07:41

Hello,

The current beta package of phpdocx includes an extra check when adding stream images without extensions with embedHTML. Please send to contact[at]phpdocx.com the version of phpdocx and if you are using the classic or namespaces package, we'll send you the updated class; if you also send a URL sample you are using we'll check it before sending the class.

Regards.