Programmatically adding Internal Link URL to an Image Block

I’m trying to programmatically add an image block to a page using the code below. I can add the image block and set the “openLinkInNewWindow” without issue. But I cannot link it to an internal page by cID.

I see where the image is being created in btContentImage and, if I manually add the link cID into the associated row, it works. I just need to be able to add it programmatically through my package.

$blockType = \BlockType::getByHandle('image');
$blockName = "BLOCKNAME";
$data = array( 
    'fID' => $thumbID, 
    'internalLinkCID' => 123, 
    'openLinkInNewWindow' => true
);
$c->addBlock($blockType, $blockName, $data);

Thank you for the info!

I tried what you mentioned and get the following error:
Call to undefined method Concrete\Block\Image\Controller::saveBctionController()

I am using v9.2.8

Unfortunately I think that user was a bot plugging things into AI and just pasting in the output.

Yeah, couldn’t find any controller actions that even came close to what they were saying.

Fortunately, I did figure it out by creating the image block, then getting the bID of the image, then updating the internalLinkCID in the btContentImage table.

1 Like

Nice, thanks for posting the solution!