Add Image Block to a Page

Permalink 1 user found helpful
Hi everyone,

I've trying to add a Image Blocktype to a Page how i create, i can add the content fine, but when i try to add an Image the C5 don't recognize.

My code:
$fi = new FileImporter();
$resp = $fi->import($dir . $noticia['noticia_chamada_imagem'], $noticia['noticia_chamada_imagem'], $fr);

if (is_object($resp)) {
$thumbID = $resp->getFileID();

$bt = BlockType::getByHandle('Image');
$data = array('content' => $resp);
$p->addBlock($bt, 'Thumbnail Image', $data);
}

The Page inclusion its OK, when i import the page this blocks show "Image Not Found".


Thank you for your help :-)

 
lucasschirm replied on at Permalink Reply
Hi everyone, i figure out how to do, but just reading the source of Image block, how can i improve the documentation of this litle aspect of Concrete5 for future developers?

Solution:

$fi = new FileImporter();
$resp = $fi->import($dir . $noticia['noticia_chamada_imagem'], $noticia['noticia_chamada_imagem'], $fr);
//$thumbFile = $this->fileset->addFileToSet($resp);
if (is_object($resp)) {
$thumbID = $resp->getFileID();

$bt = BlockType::getByHandle('Image');
$data = array('fID' => $thumbID);
$p->addBlock($bt, 'Thumbnail Image', $data);
//$p->setAttribute('thumbnail', $resp);


Thank You for community :)