Forum


Replies: 7   Views: 3583
Issue with <img> in html
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 admin  · 22-02-2018 - 13:04

Hello,

The mime type on one of our test server is image/jpeg for a JPEG image. Anyway, the important point is the output of exif_imagetype. As we can't do a direct test, we think the best approach we can recommend is to debug the image generation, the source of the issue should be in HTML2WorML.inc, around line 981, when the code gets the extension of the image ($extension variable), maybe you can test changing the extension detection or forcing an extension.

If you are using PHP5.4 or newer you can use the following code to get the extension:

$imageStream = file_get_contents($data['src']);
$attrImage = getimagesizefromstring($imageStream);
$mimeType = $attrImage['mime'];

switch ($mimeType) {
    case 'image/gif':
        $dir['extension'] = 'gif';
        break;
    case 'image/jpg':
        $dir['extension'] = 'jpg';
        break;
    case 'image/jpeg':
        $dir['extension'] = 'jpeg';
        break;
    case 'image/png':
        $dir['extension'] = 'png';
        break;
    default:
    break;
}

The embedHTML method uses other code due to compatibility reasons with old version of PHP.

Regards.