File ID from Image block

Permalink 1 user found helpful
I am trying to do something with Pagelists, I can grab all the blocks from a page and with the code below I can get the content out of a Content Block.

I would like to do something similar with an Image block and get the FIle ID of the image in the block. I've tried things like ->fID, ->getFID, those don't work, Anyone know how to do it?

Thanks
Peter

$pBlocks = $page->GetBlocks();
    foreach ($pBlocks as $pBlock){
   if ($pBlock->btHandle == 'content') {
      $blockContent = $pBlock->getInstance();
      echo $pBlock->getContent;
   }
  }

pvernaglia
 
andrew replied on at Permalink Reply
andrew
something like

if ($pBlock->getBlockTypeHandle() == 'image') {
    $controller = $pBlock->getController(); // this is the same as getinstance but slightly more semantically correct
    // $controller is an instance of \Concrete\Block\Image\Controller so all methods in that
    // class are available
    $file = $controller->getFileObject();
    if ($file instanceof \Concrete\Core\File\File) {
        // Now you have a $file block.
        print $file->getFileName();
    }
}
pvernaglia replied on at Permalink Reply
pvernaglia
Thanks, works great