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?


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

View Replies:
andrew replied on at Permalink Reply
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
Thanks, works great