问题
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:
- First try with the latest OpenTBS version (1.7.4) because it claims to fix a bug about "default=current"
- 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