One thing that has bugged me about WP-Cyle is that I had to include hard-coded URLs to linkify the rotating images. This is problem matic when I change my URLs, etc. So I just want to enter page IDs and allow WordPress to properly assign the proper URL. Download the revised/upgraded WP Cycle: [download id="12"].
For those who want to know what I did, here's what I added:
On line 393, the original code contains:
[php]if($value['image_links_to'])
$input[$key]['image_links_to'] = clean_url($value['image_links_to']);[/php]
I changed it to:
[php]if($value['image_links_to']) {
$checkhttp = substr($value['image_links_to'], 0, 4);
if ($checkhttp == 'http')
$input[$key]['image_links_to'] = clean_url($value['image_links_to']);
}[/php]
Then on line 416 in the foreach section, the original code contains:
[php]foreach((array)$wp_cycle_images as $image => $data) {
if($data['image_links_to'])
echo '<a href="'.$data['image_links_to'].'">';
echo '<img src="'.$data['file_url'].'" width="'.$wp_cycle_settings['img_width'].'" height="'.$wp_cycle_settings['img_height'].'" class="'.$data['id'].'" alt="" />';
if($data['image_links_to'])
echo '</a>';
echo $newline;
}
[/php]
I changed it to:
[php highlight="2,3,4,5,6,7,8"]foreach((array)$wp_cycle_images as $image => $data) {
if($data['image_links_to']) {
$checkhttp = substr($data['image_links_to'], 0, 4);
if ($checkhttp != 'http') {
$id = intval($data['image_links_to']);
$data['image_links_to'] = get_permalink( $id );
}
echo '<a href="'.$data['image_links_to'].'">';
}
echo '<img src="'.$data['file_url'].'" width="'.$wp_cycle_settings['img_width'].'" height="'.$wp_cycle_settings['img_height'].'" class="'.$data['id'].'" alt="" />';
if($data['image_links_to'])
echo '</a>';
echo $newline;
}
[/php]
JC says
I was hoping to find the answer here when I started reading but not quite there. Bummer. I’ve been trying to figure out a way to add a target or rel attribute to the image link to hyperlink. Problem is I don’t want this on all links, just some. To bad the plug-in doesn’t provide a drop-down selector for this.
Any ideas.
Cheers