Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Random image panel from folder

Asked Modified Viewed 5,482 times
M
m3r
M
m3r 10
  • Junior Member, joined since
  • Contributed 23 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
asked
Junior Member

where is problem? when I check him, everything ok, but the panel does not work....

<?php
opentable($locale['global_035']);
$dir = "../images/"; // The relative path to the image directory
$pictures = glob("$dir/{*.jpg,*.jpeg,*.gif,*.png}",GLOB_BRACE);
$img = $pictures[mt_rand(0,count($pictures)-1)];
echo '<img src="' . $img . '">';
closeside();
?>
m3r attached the following file:
centr.jpg [No information available / 90 Downloads]
0 replies

10 posts

A
Ankur
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums
answered
Veteran Member

It should be without <?php and ?> in a Panel. Also, make it :
openside($locale['global_035']);
closeside();


Its working for me, say :
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]openside("test");

$dir = "../images/"; // The relative path to the image directory
$pictures = glob("$dir/{*.jpg,*.jpeg,*.gif,*.png}",GLOB_BRACE);
$img = $pictures[mt_rand(0,count($pictures)-1)];
echo '<img src="' . $img . '">';

closeside();[/syntaxhighlighter]
0 replies
M
m3r
M
m3r 10
  • Junior Member, joined since
  • Contributed 23 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

how does it work with <?php and ?> ?
0 replies
A
Ankur
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums
answered
Veteran Member

Quote

m3r wrote:

how does it work with <?php and ?> ?


Oops... Ok... If you are adding the Panel from a Panel File, then you have to add <?php ?> but if you are adding the Code, then you need not to add them.
0 replies
M
m3r
M
m3r 10
  • Junior Member, joined since
  • Contributed 23 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
answered
Junior Member

do you enable panel? and its work?
0 replies
A
Ankur
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums
answered
Veteran Member

Better try this as PHP Code in a panel and its working for me :
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]opentable("test"wink;

$dir = IMAGES; // The relative path to the image directory
$pictures = glob("$dir{*.jpg,*.jpeg,*.gif,*.png}",GLOB_BRACE);
$img = $pictures[mt_rand(0,count($pictures)-1)];
echo '<img src="' . $img . '">';

closeside();[/syntaxhighlighter]
0 replies
— 3 months later —
0
0siris
0
0siris 10
  • Newbie, joined since
  • Contributed 5 posts on the community forums.
  • Started 3 threads in the forums
answered
Newbie

opentable("test"wink;

$dir = IMAGES; // The relative path to the image directory
$pictures = glob("$dir{*.jpg,*.jpeg,*.gif,*.png}",GLOB_BRACE);
$img = $pictures[mt_rand(0,count($pictures)-1)];
echo '<img src="' . $img . '">';

closeside();

Is there a way you can select a different folder rather than the IMAGES folder?

Regards
0 replies
-
- Tony -
-
www.lemviginfo.dk/platuglerne_ikon2.gif
www.lemviginfo.dk/../../images/lemvig_info.gif

Mainsite still running version 6 pfft
  • Junior Member, joined since
  • Contributed 38 posts on the community forums.
  • Started 1 thread in the forums
answered
Junior Member

openside("test"); 
$dir = BASEDIR."YOUR_FOLDER/"; // The relative path to the image directory
$pictures = glob("$dir/{*.jpg,*.jpeg,*.gif,*.png}",GLOB_BRACE);
$img = $pictures[mt_rand(0,count($pictures)-1)];
echo '<img src="' . $img . '">';
closeside();
0 replies
A
Acert
A
Acert 10
  • Member, joined since
  • Contributed 54 posts on the community forums.
  • Started 13 threads in the forums
answered
Member

Hi Tony, it works but how can i rezise the photos in the panel? the panel shows the images in their real size, its too big... so i want to put width and height in the code but.. where?
0 replies
H
HaYaLeT
H
  • Senior Member, joined since
  • Contributed 262 posts on the community forums.
  • Started 28 threads in the forums
answered
Senior Member

Try same this:

openside("test"); 
 $dir = BASEDIR."YOUR_FOLDER/"; // The relative path to the image directory
 $pictures = glob("$dir/{*.jpg,*.jpeg,*.gif,*.png}",GLOB_BRACE);
 $img = $pictures[mt_rand(0,count($pictures)-1)];
 echo '<img src="' . $img . '" width="120" height="100" alt="" />';
 closeside();


you can change width and height size..
0 replies
A
Acert
A
Acert 10
  • Member, joined since
  • Contributed 54 posts on the community forums.
  • Started 13 threads in the forums
answered
Member

thanks
0 replies

Category Forum

Panels and Infusions

Labels

None yet

Statistics

  • Views 0 views
  • Posts 10 posts
  • Votes 0 votes
  • Topic users 6 members

6 participants

-
-
www.lemviginfo.dk/platuglerne_ikon2.gif
www.lemviginfo.dk/../../images/lemvig_info.gif

Mainsite still running version 6 pfft
  • Junior Member, joined since
  • Contributed 38 posts on the community forums.
  • Started 1 thread in the forums
H
H
  • Senior Member, joined since
  • Contributed 262 posts on the community forums.
  • Started 28 threads in the forums
A
A
Acert 10
  • Member, joined since
  • Contributed 54 posts on the community forums.
  • Started 13 threads in the forums
A
A
Ankur 10
Hi! Its me, Ankur Thakur! smile
  • Veteran Member, joined since
  • Contributed 1,277 posts on the community forums.
  • Started 60 threads in the forums
M
M
m3r 10
  • Junior Member, joined since
  • Contributed 23 posts on the community forums.
  • Started 6 threads in the forums
  • Started this discussions
0
0
0siris 10
  • Newbie, joined since
  • Contributed 5 posts on the community forums.
  • Started 3 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet