Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddImage using value from PHP Object #2285

Open
Artoo23 opened this issue Aug 30, 2022 · 1 comment
Open

AddImage using value from PHP Object #2285

Artoo23 opened this issue Aug 30, 2022 · 1 comment

Comments

@Artoo23
Copy link

Artoo23 commented Aug 30, 2022

Describe the Bug

I am trying to create a word document using data from the Trello API.

The API can provide a partial URL for an avatar image. The full image URL can be derived from this by adding on details of the image size.

So the API provides something like this

"avatarUrl": "https://trello-members.s3.amazonaws.com/6059dd69783e1b38da09a50c/acdc216e9c555d2f9a9a5aaf6183775f"

and the full URL is

"https://trello-members.s3.amazonaws.com/6059dd69783e1b38da09a50c/acdc216e9c555d2f9a9a5aaf6183775f/50.png".

Whenever i try to use the object value to derive the image URL and use this in an addImage call I get a 500 error.

Steps to Reproduce

I my addImage call is in a foreach loop where I iterate through card members.

		foreach ($members as $member) {
					
		$imageStyle = array(
			'width' => 40,
			'height' => 40,
			'wrappingStyle' => 'square',
			'positioning' => 'absolute',
			'posHorizontalRel' => 'margin',
			'posVerticalRel' => 'line',
		);

		$section->addImage($member->avatarUrl . "/50.png", $imageStyle);
	
		}

Expected Behavior

PHPWord recognises the image URL and adds image to document

Current Behavior

500 Internal Server Error

Context

Please fill in your environment information:

  • PHP Version: 7.2.34
  • PHPWord Version: 0.18.3
@Artoo23
Copy link
Author

Artoo23 commented Aug 31, 2022

#0 /public_html/acq-trello/vendor/phpoffice/phpword/src/PhpWord/Element/Image.php(149): PhpOffice\PhpWord\Element\Image->checkImage()
#1 [internal function]: PhpOffice\PhpWord\Element\Image->__construct('https://cslitto...')
#2 /public_html/acq-trello/vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php(146): ReflectionClass->newInstanceArgs(Array)
#3 [internal function]: PhpOffice\PhpWord\Element\AbstractContainer->addElement('Image', 'https://cslitto...')
#4/public_html/acq-trello/vendor/phpoffice/phpword/src/PhpWord/Element/AbstractContainer.php(113): call_user_func_array(Array, Array)
#5 /public_html/acq-trello/functions.php(190): PhpOffice\P in /public_html/acq-trello/vendor/phpoffice/phpword/src/PhpWord/Element/Image.php on line 418

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant