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

cloneBlock with images inside #1750

Closed
giovanniledda opened this issue Nov 5, 2019 · 2 comments · Fixed by #1763
Closed

cloneBlock with images inside #1750

giovanniledda opened this issue Nov 5, 2019 · 2 comments · Fixed by #1763

Comments

@giovanniledda
Copy link

I desperately need to clone a block that contains images.

Steps to Reproduce

In the docx "template":

${blC_bloccoTask}
Point

${img_currentTask_brPos:450:450:false}

Point: #${task_id}
Type: ${task_type}
Location: ${task_location}

Photos
${img_currentTask_img1:250:250:false}

${img_currentTask_img2:250:250:false}

${img_currentTask_img3:250:250:false}

${img_currentTask_img4:250:250:false}

${img_currentTask_img5:250:250:false}

${pageBreak}

${/blC_bloccoTask}

In the php code:

$template_processor->cloneBlock('blC_bloccoTask', 0, true, false, $field_content_replacements);

where $field_content_replacements is generated in this way:

array:2 [▼
  0 => array:14 [▼
    "task_id" => 1
    "task_type" => "corrosion"
    "task_location" => "Starboard"
    "img_currentTask_brPos" => "/private/var/tmp/phpBs1odO.jpg"
    "pageBreak" => "</w:t></w:r><w:r><w:br w:type="page"/></w:r><w:r><w:t>"
    "img_currentTask_img1" => "/private/var/tmp/storage/app/28/photo1.jpg"
    "img_currentTask_img2" => "/private/var/tmp/storage/app/29/photo2.jpg"
    "img_currentTask_img3" => "/private/var/tmp/storage/app/30/photo3.jpg"
    "img_currentTask_img4" => "/private/var/tmp/storage/app/31/photo4.jpg"
    "img_currentTask_img5" => "/private/var/tmp/storage/app/32/photo5.jpg"
  ]
  1 => array:14 [▼
    "task_id" => 2
    "task_type" => "other"
    "task_location" => "Starboard"
    "img_currentTask_brPos" => ""
    "pageBreak" => "</w:t></w:r><w:r><w:br w:type="page"/></w:r><w:r><w:t>"
    "img_currentTask_img1" => "/private/var/tmp/storage/app/33/photo1.jpg"
    "img_currentTask_img2" => "/private/var/tmp/storage/app/34/photo2.jpg"
    "img_currentTask_img3" => "/private/var/tmp/storage/app/35/photo3.jpg"
    "img_currentTask_img4" => "/private/var/tmp/storage/app/36/photo4.jpg"
    "img_currentTask_img5" => "/private/var/tmp/storage/app/37/photo5.jpg"
  ]
]


Everything is fine for the "basic" placeholders (the strings, like "task_id", "task_type", "task_location")...but nothing happens when the replacement involves an image.

Any idea?

Context

  • PHP Version: 7.2
  • PHPWord Version: "phpoffice/phpword": "v0.17.*"
alarai pushed a commit to TimeTonic/PHPWord that referenced this issue Nov 28, 2019
… part after the #number and fixing Process call to array instead of string
@Amerlander
Copy link

would also fix #1624

@answer666
Copy link

hello Have you solved this problem?

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

Successfully merging a pull request may close this issue.

3 participants