TemplateProcessor::setImageValue() inserts images as legacy VML — not editable in Word Mobile / Word Online
Describe the bug and add attachments
TemplateProcessor::setImageValue() injects images using a hard-coded VML template:
$imgTpl = '<w:pict><v:shape type="#_x0000_t75" style="width:{WIDTH};height:{HEIGHT}" stroked="f" filled="f"><v:imagedata r:id="{RID}" o:title=""/></v:shape></w:pict>';VML (<w:pict>/<v:shape>/<v:imagedata>) is the legacy Office 2007 markup. Desktop Word renders and edits it fine, but Word Mobile and Word Online display the injected image WITHOUT any editing UI — no move, resize or crop handles.
Images authored by Word itself use DrawingML (<w:drawing>/<wp:inline>/<a:blip>/<pic:pic>), which is fully editable on every platform. As a result, images already present in the source template are editable on mobile, but images injected via setImageValue() are not.
Source: src/PhpWord/TemplateProcessor.php (the $imgTpl in setImageValue()).
Expected behavior
Images injected by setImageValue() should behave like native Word images (selectable, movable, resizable, croppable) on all platforms, including Word Mobile and Word Online.
This requires emitting DrawingML (an inline picture) instead of VML: <w:drawing><wp:inline> with an EMU extent, a unique docPr/cNvPr id, <a:blip r:embed>, and <pic:spPr> containing <a:xfrm> + <a:prstGeom prst="rect"/>. Pixel dimensions must be converted to EMU (1 px = 9525 EMU).
Steps to reproduce
- Create a .docx template with an image placeholder ${myImage}.
- Load it with TemplateProcessor and call $tp->setImageValue('myImage', ...).
- Save and open the result in Word Mobile or Word Online.
- Tap the image → no editing handles appear (move/resize/crop unavailable).
PHPWord version(s) where the bug happened
1.4.0
PHP version(s) where the bug happened
8.4
Priority
- I want to crowdfund the bug fix (with @algora-io) and fund a community developer.
- I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)
Source: PHPOffice/PHPWord