Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
I would like to dynamically generate documents to use as a template for templates. Sounds strange I know. Basically, I don't want to make my end users have to deal with right clicking images and adjusting the alt text manually.
So, how can I insert an image into a document and set its alt text to something specific?
Never mind, I figured this out.
For anyone else looking for the same thing:
Then simply add a 'description' key to your params array when you call addImage()
It would be nice to have this in future versions, its a very useful feature that can be done with a line of code.
The current version of phpdocx can¡t add the alt image using addImage method, so I recommend you to add a simple placeholder and use replaceTemplateVariableByHTML to replace it using an image.
Or change the code as you've done :).
I'm aware of that limitation. I am trying to do something else.
In my case, my clients are the ones making the templates, I am effectively making a template for their templates; a word document with the available images already embedded with the alt text, so that they can copy/paste right into their own templates without having to manually edit alt text themselves, which is not particularly user friendly.