Skip to content

cloneBlock with images inside #1750

@giovanniledda

Description

@giovanniledda

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.*"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions