Extract full Image Path from page image area

Permalink
Hi,

Ik like to get the full image url in a link from the image set on the page using a imageblock in composer.

If I try the code below ik get the full block after v1:
<img border="0" class="ccm-image-block" alt="" src="/xxx/xxx/files/1614/5751/3096/P1030398.jpg" width="722" height="481" />

I only like to get the full url, so:http://www.xxx.xx/xxx/files/1614/5751/3096/P1030398.jpg...

Getting the image in the template
<?php
  $a= new Area ('Thumbnail Image Big');
  $a->display($c);
 ?>


Code to display url in link.
<a href="http://www.xxx.xx/infopage/infopage.php?hash=xxx&v1=<?php $a = new Area('Thumbnail Image Big'); $a->display($c); ?>&v2=<?php echo $c->getCollectionAttributeValue('xxx'); ?>">Link</a>

How do I get the full url?

 
pvernaglia replied on at Permalink Reply
pvernaglia
What are you trying to accomplish. have a link open the image block?
studio4graphics replied on at Permalink Reply
To fetch the complete url (http://...) of the image called in the Area "Thumbnail Image Big" on the same page (placed using composer). And put it in a link:

<a href="http://www.xxx.xx/infopage/infopage.php?has=xxx&v1=[b]IWANTTHEURLHERE[/b]&v2=......">


Now it places the whole block with img tag etc..
studio4graphics replied on at Permalink Reply
Bump
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi studio4graphics,

What is generating the link in your example?
http://www.xxx.xx/infopage/infopage.php?has=xxx&v1=

Aside from the full URL of the image, will this link be hard coded or dynamic?
studio4graphics replied on at Permalink Reply
Hi MrKDilkington,

It is a hardcoded link and I need to put some value's after &v1=[value1]&v2=[value2]etc.
".../infopage.php?hash=xxx&v1=&v2=&v3="
A3020 replied on at Permalink Best Answer Reply
A3020
How about something like this?

$a = new Area('Thumbnail Image Big');
$blocks = $a->getAreaBlocksArray();
foreach ($blocks as $b) {
    $bt = BlockType::getByID($b->getBlockTypeID());
    if($bt->getBlockTypeHandle() == 'image') {
        $controller = $b->getController();
        $fID = $controller->fID;
        if ($fID) {
            $file = File::getByID($fID);
            if ($file) {
                echo $file->getVersion()->getRelativePath();
            }
        }
    }
}
studio4graphics replied on at Permalink Reply
Hi A3020,
Thank you for your code,.. it gave me an error (because it was missing $c > getAreaBlocksArray();), but I fixed it. And changed the output of the link. Thanks so much, was exactly what I was looking for!

<?php
   $a = new Area('Thumbnail Image Big');
   $blocks = $a->getAreaBlocksArray($c);
   foreach ($blocks as $b) {
   $bt = BlockType::getByID($b->getBlockTypeID());
      if($bt->getBlockTypeHandle() == 'image') {
      $controller = $b->getController();
      $fID = $controller->fID;
      if ($fID) {
         $file = File::getByID($fID);
         if ($file) {
         echo BASE_URL . $file->getVersion()->getRelativePath();
         }
      }
    }
A3020 replied on at Permalink Reply
A3020
Ok, I'm glad this is what you were after. PS. You mind find this topic interesting too:https://www.concrete5.org/community/forums/5-7-discussion/area-backg...