Supports loading of word files with images added on OneDrive
Description
Add images by editing Word in OneDrive and download Word files locally
When loaded with PhpOffice\PhpWord\IOFactory::load
Fixed a bug that caused PhpOffice\PhpWord\Exception\InvalidImageException.
If you unzip a normal Word file with zip /docProps /word /_rels Image files are in the directory It is saved as /word/media/xxx.png.
However, if it is a file with images added with OneDrive
/docProps
/media
/word
/_rels
It is stored in the media directory of the directory called
In getRels of PhpOffice\PhpWord\Reader\Word2007 Since it is assumed that the image exists in the /word/mediadirectory, The image in the/media` directory could not be read and an error occurred.
for that reason, If a directory has a "/" at the beginning, it has been modified to refer to that directory.
Fixes #2245
Checklist:
- [x] I have run
composer run-script check --timeout=0and no errors were reported
An error was reported where it had nothing to do with the fix.
Checked all files in 0.680 seconds, 12.000 MB memory used
> phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --ignore=src/PhpWord/Shared/PCLZip --standard=PSR2 -n
> phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
/path/to/PHPWord/src/PhpWord/Element/TOC.php:27 CamelCasePropertyName The property $TOCStyle is not named in camelCase.
- [x] The new code is covered by unit tests (check build/coverage for coverage report)
- [x] I have updated the documentation to describe the changes There was no description because it was a minor bug fix.
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue for you, please try to complete the PR by adding tests and making sure that the CI is green. Thank you for your contributions.
What's the status for this PR? This fixes an issue we're having, is there anything we can do to make it easier for you to merge? : )