Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Probably pretty easy solved php issue ...
Old 04-08-2010, 02:49 PM Probably pretty easy solved php issue ...
Novice Talker

Posts: 14
Trades: 0
Hi!

Im using an random image script which works fine but that I want to edit a bit. I have edited it a bit so when you click on a image you get a fullsize in a popup. The problem is that the image in the popup is also random and not always a bigger copy of the thumbnail, the smaller one you clicked on as I want:

see it live here, and I think you will understand what I want to achieve:
katapultforlag.com/page.php?37

the code Im using is:
randim.php
PHP Code:
<?php
/* The default folder with images */
$settings['img_folder'] = 'bildermini/';

/* File types (extensions) to display */
$settings['img_ext'] = array('.jpg','.gif','.png');

/*
   How to display the images?
   0 = print just the image path (for includes), like: images/test.jpg
   1 = redirect to the image, when using: <img src="randim.php" />
*/
$settings['display_type'] = 1;

/* Allow on-the-fly settings override? 0 = NO, 1 = YES */
$settings['allow_otf'] = 1;

/*******************************************************************************

/* Override type? */
if ($settings['allow_otf'] && isset($_GET['type']))
{
    
$type intval($_GET['type']);
}
else
{
    
$type $settings['display_type'];
}

/* Override images folder? */
if ($settings['allow_otf'] && isset($_GET['folder']))
{
    
$folder htmlspecialchars(trim($_GET['folder']));
    if (!
is_dir($folder))
    {
        
$folder $settings['img_folder'];
    }
}
else
{
    
$folder $settings['img_folder'];
}

/* Make sure images fodler ends with an '/' */
if (substr($folder,-1) != '/')
{
    
$folder.='/';
}

/* Get a list of all the image files */
$flist = array();
foreach(
$settings['img_ext'] as $ext)
{
    
$tmp glob($folder.'*'.$ext);
    if (
is_array($tmp))
    {
        
$flist array_merge($flist,$tmp);
    }
}

/* If we have any images choose a random one, otherwise select the "noimg.gif" image */
if (count($flist))
{
    
$src $flist[array_rand($flist)];
}
else
{
    
$src 'noimg.gif';
}

/* Output the image according to the selected type */
if ($type)
{
    
header('Location:'.$src);
    exit();
}
else
{
    echo 
$src;
}
?>
and for calling it:
test.php
Code:
<ol>
click for bigger image:
<li>
<a class="fancy" rel="fancy" href="<?php $_GET['type']=0; $_GET['folder']='bilderstora'; include 'randim.php'; ?>"><img border='0' src="<?php $_GET['type']=0; $_GET['folder']='bildermini'; include 'randim.php'; ?>"></a></p>
</li>
<li>
<a class="fancy" rel="fancy" href="<?php $_GET['type']=0; $_GET['folder']='bilderstora'; include 'randim.php'; ?>"><img border='0' src="<?php $_GET['type']=0; $_GET['folder']='bildermini'; include 'randim.php'; ?>"></a></p>
</li>
<li>
<a class="fancy" rel="fancy" href="<?php $_GET['type']=0; $_GET['folder']='bilderstora'; include 'randim.php'; ?>"><img border='0' src="<?php $_GET['type']=0; $_GET['folder']='bildermini'; include 'randim.php'; ?>"></a></p>
</li>
</ol>
how do I edit the code so I get the same image on the link as it is on the thumbnail?

the images are stored in:
bildermini/ (thumbnails)
bilderstora/ (big image)

thanks for your help!

Perik
perik is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Probably pretty easy solved php issue ...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26795 seconds with 12 queries