Keyword

Extra Fields image field - Get url of the image

  • Melinda McCaw
  • Melinda McCaw's Avatar Topic Author
  • Offline
  • New Member
More
10 years 8 months ago #123717 by Melinda McCaw
I have created an extra field that is an image and am using
<?php echo $this->item->extraFields->PartImageOne->value; ?>
to pull in the image. This works great but I want to wrap the image tag in an <a> tag and set it up to open the prettyphoto lightbox when the image is clicked.

To do so I need to be able to just populate the href in the <a> tag with the source url of the image like this:
<a href="path/to/image" rel="prettyPhoto"><?php echo $this->item->extraFields->PartImageOne->value; ?></a>

How do I get the url of the image so I can use it in my <a>?

Thanks!

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 8 months ago #123718 by Yiota
Hello,

Try to use something like
<?php $fetchSrc1 = explode('src="', $this->item->extraFields->PartImageOne->value); 
$fetchSrc2 = explode('"', $fetchSrc1[1]);
?>

<a href="<?php echo $fetchSrc2[0]; ?>" rel="prettyPhoto"><?php echo $this->item->extraFields->PartImageOne->value; ?></a>

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum