Old 06-15-2007   #1 (permalink)
Small Fish In A Big Pond
 
stiney51's Avatar
 
Join Date: May 2006
Location: Maine, USA
Posts: 532
Blog Entries: 16

Joomla Random Image Help

Mike might be able to help with this one... I'm trying to use Joomla's random image module on a site I'm working on. I can't figure out how to modify it so when I click on the displayed image it links a to a new window with the full size image.

here's the site: www.foxridgeonline.org

There's a "link" option in the module, but it seems to only be able to go to a specific address, not based on the image that you are clicking on.

Any ideas?

here's the PHP for the module:

<?php
/**
* @version $Id: mod_random_image.php 2742 2006-03-11 18:15:33Z stingrey $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license GNU General Public License - GNU Project - Free Software Foundation (FSF) GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

global $mosConfig_absolute_path, $mosConfig_live_site;

$type = $params->get( 'type', 'jpg' );
$folder = $params->get( 'folder' );
$link = $params->get( 'link' );
$width = $params->get( 'width' );
$height = $params->get( 'height' );
$the_array = array();
$the_image = array();

// if folder includes livesite info, remove
if ( strpos($folder, $mosConfig_live_site) === 0 ) {
$folder = str_replace( $mosConfig_live_site, '', $folder );
}
// if folder includes absolute path, remove
if ( strpos($folder, $mosConfig_absolute_path) === 0 ) {
$folder= str_replace( $mosConfig_absolute_path, '', $folder );
}
// if folder doesnt contain slash to start, add
if ( strpos($folder, '/') !== 0 ) {
$folder = '/'. $folder;
}
// construct absolute path to directory
$abspath_folder = $mosConfig_absolute_path . $folder;

// check if directory exists
if (is_dir($abspath_folder)) {
if ($handle = opendir($abspath_folder)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && $file != 'CVS' && $file != 'index.html' ) {
$the_array[] = $file;
}
}
}
closedir($handle);

foreach ($the_array as $img) {
if (!is_dir($abspath_folder .'/'. $img)) {
if (eregi($type, $img)) {
$the_image[] = $img;
}
}
}

if (!$the_image) {
echo _NO_IMAGES;
} else {
$i = count($the_image);
$random = mt_rand(0, $i - 1);
$image_name = $the_image[$random];
$abspath_image = $abspath_folder . '/'. $image_name;
$size = getimagesize ($abspath_image);

if ($width == '') {
($size[0] > 100 ? $width = 100 : $width = $size[0]);
}
if ($height == '') {
$coeff = $size[0]/$size[1];
$height = (int) ($width/$coeff);
}

$image = $mosConfig_live_site . $folder .'/'. $image_name;
?>
<div align="center">
<?php
if ($link) {
?>
<a href="<?php echo $link; ?>" target="_self">
<?php
}
?>
<img src="<?php echo $image; ?>" border="0" width="<?php echo $width; ?>" height="<?php echo $height; ?>" alt="<?php echo $image_name; ?>" /><br />
<?php
if ($link) {
?>
</a>
<?php
}
?>
</div>
<?php
}
}
?>
stiney51 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-15-2007   #2 (permalink)
Small Fish In A Big Pond
 
stiney51's Avatar
 
Join Date: May 2006
Location: Maine, USA
Posts: 532
Blog Entries: 16

BTW, I should mention that I have virtually 0 coding experience so even a point in the right direction to understanding the PHP code would be helpful.
stiney51 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-15-2007   #3 (permalink)
photoshop ninja
 
agentxi's Avatar
 
Join Date: Oct 2006
Location: Red Deer - ish, alberta
Posts: 499

Hey Stiney,

I'm not a php guru either...so i try and find modules that mostly do what i need it to do without a lot of maintenance.

Another thing I tend to do is search the forums on www.joomla.org

With a quick search over there, I did find this thread. If you're willing to try it could be helpful: link from random image mod

Another option is to go with my first suggestion: to look for a module that will do what you need.

and I found a slideshow that will allow html, meaning you can create a link to whatever URL you want. here's the link

Sorry I didn't answer your question directly, but I hope I helped out. Mike might know more on the subject, or some other php guru
__________________

Your a Graphic Designer...If you could go back in time you wouldn't go back to see the rise and fall of civilizations, you'd go back in time to destroy comic sans and papyrus.
agentxi is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-20-2007   #4 (permalink)
Rusty Bio-Hazard!
 
notjustgraphics's Avatar
 
Join Date: Sep 2006
Location: Toronto, Ontario, Canada
Posts: 1,026

Send a message via MSN to notjustgraphics
Wow Stiney, somehow I missed this post... But i think we took care of it through Private Messaging...

For anyone else looking for a quick fix to the same problem, changing line 84 of the source code to read:

<a href="<?php echo $image; ?>" target="_self">

instead of

<a href="<?php echo $link; ?>" target="_self">

should work!

Mike.
__________________
notjustgraphics is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-20-2007   #5 (permalink)
Small Fish In A Big Pond
 
stiney51's Avatar
 
Join Date: May 2006
Location: Maine, USA
Posts: 532
Blog Entries: 16

As Mike suggested I made the modification (except changing _self to _blank since I wanted it to launch in the new window).

It worked for exactly what I needed it for! Thanks again eh!
stiney51 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-28-2008   #6 (permalink)
Registered User
 
Join Date: Apr 2008
Posts: 1

Joomla 1.5 help with random image links

Hi,
I found this thread via the internet and it's just what I'm looking for, although I can't seem to find the source code quoted in the original post. Is that code from Joomla 1.0? I'm trying to get the random images to link to larger versions of themselves in Joomla 1.5. Is the process the same? Can someone show me the source code I need to edit?
Thanks in advance,
John
jchick is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cutting out an image Phoenix Wynde BioRUST Specific Threads 5 09-11-2006 11:37 PM
Random Image Verification B44h HTML / PHP / ASP / JS 3 08-21-2006 01:03 AM
Free Image Hosting baxterboy The Marketplace 2 06-24-2006 06:46 AM
CSS hover tutorial Telos Tutorial Submission 7 06-09-2006 06:38 AM
Random images php code? supafly HTML / PHP / ASP / JS 7 12-07-2005 12:49 AM


All times are GMT +1. The time now is 08:45 PM.
Content Relevant URLs by vBSEO 3.2.0 RC7

Design & Content © BioRUST 2007 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT