Image's "link_to_url" attribute

Permalink Browser Info Environment
Thanks for a very useful block. I have been trying to edit it slightly to try and use the file attribute "link_to_url" set within the image properties.

Basically we want to be able to have a different link url set for each image, with this link url being put in the images properties in the "link_to_url" attribute. We won't be using the blocks link url option at all, just relying on the images attribute.

I just can't seem to grasp how to retrieve that attribute and place it into our new template. (a complete php newbie)

Are you able to offer any assistance on how this might be achieved.

Many thanks

Kelv

Type: Discussion
Status: New
jjcdesign
View Replies: View Best Answer
jordanlev replied on at Permalink Best Answer Reply
jordanlev
Sure. Make 2 changes to this file:
/packages/random_image/blocks/random_image/controller.php


1) Find this line of code (should be around line #69):
$image->title = $file->getTitle();

...and directly below that, add this new line of code:
$image->url = $file->getAttribute('link_to_url');


2) Find this line of code (should be around line #34):
$linkUrl = empty($this->linkToCID) ? '' : Loader::helper('navigation')->getLinkToCollection(Page::getByID($this->linkToCID));

...and change it to this:
$linkUrl = empty($imageObject) ? '' : $imageObject->url;


Best,
Jordan
jjcdesign replied on at Permalink Reply
jjcdesign
Thank you so much, worked perfectly :-)

Would never have got there on my own - I have soooo much to learn!


Thanks, once again for your quick response and all the advice and help throughout the rest of this forum.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.