Search code examples
phpopentbstinybutstrong

image in OpenTBS not changing


I'm trying to show a series of pictures and comments in a document with OpenTBS. The pictures are hosted on a local webserver. The data is in an array. In the resulting document the text lines are rendered as expected, but the sample image is not changed.

When I copy paste the url location in my browser it shows a picture without problem.

With setting "$NoErr = false;" there is no error message.

What am I doing wrong?

My template:

[imgs; block=begin]
<a sample image>[imgs.url;ope=changepic]
Location: [imgs.url]
Description: [imgs.txt]
[imgs; block=end]

In my PHP code (a.o.):

$imgs = array();
$imgs[] = array('url'=>'http://192.168.0...', 'txt'=>'Sample 1');
$imgs[] = array('url'=>'http://192.168.0...', 'txt'=>'Sample 2');

$OOo->MergeBlock('imgs', $imgs);
$OOo->Show(OPENTBS_DOWNLOAD, 'file.docx');

Update: same problem when I change the url to some public available images on the web.


Solution

  • OpenTBS uses the following 3 functions in order to instert a picture into the current document :

    • file_exists()
    • filesize()
    • file_get_contents()

    While the function file_get_contents() usually works for an URL, the tow other functions file_exists() and filesize() return false despite the PHP documentation says they can supports http protocol.

    So the behavior you have probably come from file_exists() returning false for you url.

    The workaround I suggest is to download the file as a temporary file, then insert it into the document.