Replies: 4   Views: 3422
Change alt text for image
Topic closed:
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.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by asher  · 26-11-2012 - 07:23

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?


Posted by asher  · 11-04-2013 - 12:13

Never mind, I figured this out.

For anyone else looking for the same thing:


// $this->setName($args[0]['name']);

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.

Posted by admin  · 11-04-2013 - 12:13


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 :).


Posted by asher  · 11-04-2013 - 12:13

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.