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
Code to display url in link.
How do I get the full url?
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?
What are you trying to accomplish. have a link open the image block?
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:
Now it places the whole block with img tag etc..
<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..
Bump
Hi studio4graphics,
What is generating the link in your example?
Aside from the full URL of the image, will this link be hard coded or dynamic?
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?
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="
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="
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(); } } } }
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!
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(); } } }
Viewing 15 lines of 17 lines. View entire code block.
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...