openTBS remove image when replace not found

微笑、不失礼 提交于 2019-12-10 11:38:12

问题


How do you remove the image in OpenTBS if the one you are replacing it with does not exist?

I have a bit of code that loops through and replaces pics in a table, but sometimes the client will not have the pictures. I tried leaving out the default=current tag but it shows a missing image box("This image cannot currently be displayed").

UPDATE:

I thought Skrols answer would work but I couldnt get it to work. I have an image followed by the following tag.

[field.p5;ope=changepic;from=’[val]’;adjust]

Whats tags following this would i have to use to say if the field variable p5 is not set or empty ect then remove the image.


回答1:


If your first need is to not change the picture in the Docx if the target picture is a not found file, then they are two solutions:

  1. First try with the latest OpenTBS version (1.7.4) because it claims to fix a bug about "default=current"
  2. If it does not work, then you have to check at the PHP side if the target picture does exist using file_exists(). If it doesn't exist then change the target picture path with a new file that you are sure it does exist.

If you prefer to delete the picture box in the document if the file is missing, then you can add a TBS field that will delete the picture box depending to a global variable.

PHP:

$picok = (file_exists($the_picture)) ? 1 : 0;

HTML:

[onshow;block=w:drawing;when [var.picok]=1]


来源:https://stackoverflow.com/questions/7938030/opentbs-remove-image-when-replace-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!