Output src of image not entire tag

Permalink
Hi

I am using the following code.

<?php $im = Loader::helper('image');
$image= $c->getCollectionAttributeValue('BackgroundImage');
if (is_object($image)) {$im->output($image);}?>


This outputs the image tag. How do I get it to output the src of the image instead?

Probably incredibly simple, but I'm quite new to C5 development and PHP.

Thanks

Luke

View Replies: View Best Answer
Shotster replied on at Permalink Best Answer Reply
Shotster
Hi Luke,

I think what you want is...

$imgSrc = $image->getRelativePath();


I don't think you need the image helper in this case.

-Steve
lukestratton replied on at Permalink Reply
Thanks a lot, works perfectly.

I changed my code to this for reference:

<?php 
$image= $c->getCollectionAttributeValue('BackgroundImage');
if (is_object($image)) {$imgSrc = $image->getRelativePath();};
?>

and then output the src like this:

<?php echo $imgSrc; ?>


Thanks

Luke