Forum


Replies: 4   Views: 4475
"replacetemplatevariablebyhtml" and "downloadimages"
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 HalloWelt  · 11-04-2013 - 12:13

I think I found the problem: My template has already an image embedded. Therefore the "[Content_Types].xml" already had the entry[code]
<Default Extension="jpg" ContentType="image/jpeg"/>
[/code]
Now that my HTML contained other JPEGs, PHPDOCX adds the line[code]
<Default Extension="jpg" ContentType="image/jpg"/>
[/code] to "[Content_Types].xml". Now there are two entries for the file extension "jpg", one mapping to MIME type "image/jpeg" and one mapping to MIME type "image/jpg". Btw. "image/jpeg" seems to be the official one.

The cause of the issue is in "CreateTemplate::addContentTypes()" in "classes/conf/CreateTemplate.inc:390":[code]
//let´s check that tha conten type does not exist yet
if(strpos(self::$_contentTypes, $args[0]) === false){
$domContentTypes = new DomDocument();
[...]
self::$_contentTypes = $domContentTypes->saveXML();
}[/code]

'strpos()' doesn't find a "default extension" entry with ContentType "image/jpg" and therefore it gets added.
Going back in the call stack I found that in the same file in line 1691 ("CreateTemplate::TemplateHTMLRels()")[code]
$this->addContentTypes('<Default Extension="'.$extension.'" ContentType="image/'.$extension.'"/>');
[/code]
gets called, with the assumption that the proper MIME type / ContentType for an image with the file extension "X" ist "image/X". Maybe this need to be fixed.

I'd like to file a bug on this topic. Is there a bugtracker?