$docx->addTemplateVariable($field2,$imagepath,'html');
$FIELD2_IMAGES$
When i tried to insert an image into the word document, the images where not appearing.
I could see a blank page for that image.
I use custom build function to loop through the glob to look for all images and split to the word.
function images($docx,$field1,$field2,$inspector_name,$inspector_session)
{
$inspection_type = "BuildingReport-";
$folder_final = 'uploads'.'/'.$inspector_name.'/'.$inspector_session.'/'.$inspection_type;
// Scanning the thumbnail folder for JPG images:
$g = glob($folder_final.'/original/*.jpg');
if(!$g){
$g = array();
}
$names = array();
$section = array();
$modified = array();
// We loop though the file names returned by glob,
// and we populate a second file with modifed timestamps.
$image_section = $field1;
$j = 1;
$imageString = '';
for($i=0,$z=count($g);$i<$z;$i++){
if(strstr($g[$i],$image_section)!=FALSE)
{
$imageString .= "<img width=\"300\" height=\"225\" src=\"http://www.test.com/form/".$g[$i]."\"><br><br>";
$imageStringArr[] = "<img src=\"".$g[$i]."\">";
}
}
if(sizeof($imageStringArr)!=0)
{
$docx->addTemplateVariable($field2,$imageString,'html');
}
else
{
$docx->addTemplateVariable($field2, '');
}
}
Can you please tell me what i am doing wrong. Is there any alternative functions that i could use ?