I've just made some successful tests with modifyInputFields($data), to replace some text in a document containing plain text Content Controls.
But how would one go about changing Content Control Images?
I've just made some successful tests with modifyInputFields($data), to replace some text in a document containing plain text Content Controls.
But how would one go about changing Content Control Images?
Hello,
Images can be replaced using replacePlaceholderImage (https://www.phpdocx.com/api-documentation/templates/replace-placeholder-image-Word-document). Content control images should be changed using this same method.
Regards.
Regular images with the placeholder variable name as alt text works, but not quite what I need.
I'm after is using content controls, which use label/key for identifying, and that doesn't seem to work with replacePlaceholderImage, nor does the documentation mention it works with content controls.
Is there an example of replacing images in document for content control image?
Edit:
Reason I need it, instead of using the alt-text method, is that it would take a lot more time to explain to users both how to use content controls, and now also having to use alt-text. I quickly gets confusing and overwhelming for non-word-experts.
Hello,
A picture content control can include an alt text content so it can be used with replacePlaceholderImage to replace the image. Sorry, but the current stable version doesn't include a method to replace a picture content control by the title or tag value of a content control.
The modifyInputFields method only replaces input contents such as rich text content controls; so a new method should be generated for picture content controls. We have added a new task to add it in a future release of phpdocx.
Regards.
Thanks for taking the time to explain, I understand.
The purpose of using content control and it's alias/key is kind of defeated if you also have to enter it in the alt-text. The alt-text is there for another purpose - screen readers - not sure how it'll act with variables in there, but guess I'll find out.. Seems like a bit of a hack currently, but I also realize why you'd do that initially :)
Sadly I'm on Advanced license, so I will not be benefiting from the added feature in the future.