SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: zapiy on October 10, 2009, 01:33:53 PM

Title: Slideshow or Image rotator
Post by: zapiy on October 10, 2009, 01:33:53 PM
I use a php slideshow on my smf1.1.10 and tp 1.03 site and i want to use a similar thing on my next site..

Which is smf 2.0 and simple portal (latest ver)

Cheers
Title: Re: Slideshow or Image rotator
Post by: Nathaniel on October 11, 2009, 02:41:53 AM
Put the code below into a custom PHP block.
Code: [Select]
$images = array(
    'image1_url',
    'image2_url',
    'image3_url',
    'image4_url',
);

$delay = 1;

$num_images = count($images);
echo '
<img id="slideshow" src="" />
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
    var images = [';

for ($i = 0; $i < $num_images; $i++)
    echo '["', $images[$i], '"]', ($i == $num_images - 1) ? '' : ',';
   
echo '];
    var current_image = 0;
    var num_images = ', $num_images, ';
    var timer;

    function changeImage()
    {
        if (current_image == num_images)
            current_image = 0;
        document.getElementById("slideshow").src = images[current_image];
        current_image = current_image + 1;
        var timer = setTimeout("changeImage();", ', $delay * 1000, ');
    }

    changeImage();
    // ]]></script>';

Change the $delay variable to change the ammount of time between slides, change the $images variable to the list of image urls that you want to show.
Title: Re: Slideshow or Image rotator
Post by: zapiy on October 11, 2009, 12:58:45 PM
Nice one, works a treat.
Title: Re: Slideshow or Image rotator
Post by: dang2k on June 24, 2010, 10:28:02 AM
Dear sir,
I don't no how to insert image url  'image1_url' , please help me, Thanks you.

I have insert on Help.template.php file
$images = array(
$settings['image_url'] = "'/Big_set/b-picture1.jpg'",
$settings['image_url'] = "'/Big_set/b-picture1.jpg'",
$settings['image_url'] = "'/Big_set/b-picture1.jpg'",
$settings['image_url'] = "'/Big_set/b-picture1.jpg'",
);

$delay = 1;

$num_images = count($images);
echo '
<img id="slideshow" src="" />
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var images = [';

for ($i = 0; $i < $num_images; $i++)
echo '["', $images[$i], '"]', ($i == $num_images - 1) ? '' : ',';

echo '];
var current_image = 0;
var num_images = ', $num_images, ';
var timer;

function changeImage()
{
if (current_image == num_images)
current_image = 0;
document.getElementById("slideshow").src = images[current_image];
current_image = current_image + 1;
var timer = setTimeout("changeImage();", ', $delay * 1000, ');
}

changeImage();
// ]]></script>';
Title: Re: Slideshow or Image rotator
Post by: Maarten on June 24, 2010, 11:31:36 AM
Dear sir,
I don't no how to insert image url  'image1_url' , please help me, Thanks you.

I have insert on Help.template.php file
$images = array(
$settings['image_url'] = "'/Big_set/b-picture1.jpg'",
$settings['image_url'] = "'/Big_set/b-picture1.jpg'",
$settings['image_url'] = "'/Big_set/b-picture1.jpg'",
$settings['image_url'] = "'/Big_set/b-picture1.jpg'",
);

$delay = 1;

$num_images = count($images);
echo '
<img id="slideshow" src="" />
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var images = [';

for ($i = 0; $i < $num_images; $i++)
echo '["', $images[$i], '"]', ($i == $num_images - 1) ? '' : ',';

echo '];
var current_image = 0;
var num_images = ', $num_images, ';
var timer;

function changeImage()
{
if (current_image == num_images)
current_image = 0;
document.getElementById("slideshow").src = images[current_image];
current_image = current_image + 1;
var timer = setTimeout("changeImage();", ', $delay * 1000, ');
}

changeImage();
// ]]></script>';
Eey, I found the mistake?
$images = array(
$settings['image_url'] = "'/Big_set/b-picture1.jpg'",
$settings['image1_url'] = "'/Big_set/b-picture1.jpg'",
$settings['image2_url'] = "'/Big_set/b-picture1.jpg'",
$settings['image3_url'] = "'/Big_set/b-picture1.jpg'",
);

Idk what the script does, but you forgot to insert the numbers???
Title: Re: Slideshow or Image rotator
Post by: Nathaniel on June 24, 2010, 11:43:45 AM
Try:
Code: [Select]
$images = array(
    '/Big_set/b-picture1.jpg',
    '/Big_set/b-picture1.jpg',
    '/Big_set/b-picture1.jpg',
    '/Big_set/b-picture1.jpg',
);

for the images array part of the code.
Title: Re: Slideshow or Image rotator
Post by: dang2k on June 25, 2010, 12:59:33 PM
Dear Sir,
       I have alreday put the code follow your suggestion and it abnormal working because it not found image to display. In my opinion(not sure), the url in form of php is wrong?

note:
-I use SMF 10.1.11 and put the code on index.themplate.php
C:\AppServ\www\telemusic\Themes\ciziksehir\images\Big_set    -> image url
C:\AppServ\www\telemusic\Themes\ciziksehir\index.template.php  -> file script to insert

Please advice me how to correct. Thanks you.  (Sorry, I'm not advance in english)

$images = array(  '/Big_set/b-picture1.jpg', '/Big_set/b-picture2.jpg', '/Big_set/b-picture3.jpg', '/Big_set/b-picture4.jpg', );
$delay = 1;
$num_images = count($images);
echo '
<img id="slideshow" src="" />
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var images = [';
for ($i = 0; $i < $num_images; $i++)
echo '["', $images[$i], '"]', ($i == $num_images - 1) ? '' : ',';
echo '];
var current_image = 0;
var num_images = ', $num_images, ';
var timer;
function changeImage()
{
if (current_image == num_images)
current_image = 0;
document.getElementById("slideshow").src = images[current_image];
current_image = current_image + 1;
var timer = setTimeout("changeImage();", ', $delay * 1000, ');
}
changeImage();
// ]]></script>';
Title: Re: Slideshow or Image rotator
Post by: Nathaniel on June 25, 2010, 10:55:16 PM
"C:\AppServ\www\telemusic\Themes\ciziksehir\images\Big_set" is not a url, that is a file path.

A url looks like this 'http://www.site.com/Big_set/b-picture1.jpg' (which is what you currently have for the images array).
Title: Re: Slideshow or Image rotator
Post by: dang2k on June 26, 2010, 03:08:28 AM
Dear Nathaniel,

     Thanks you for your response. I'm just understand for the url is 'http://www.site.com/Big_set/b-picture1.jpg'.
So, if I would like to use image path how could I perform that?

Note: For the array(  '/Big_set/b-picture1.jpg', '/Big_set/b-picture2.jpg', '/Big_set/b-picture3.jpg', '/Big_set/b-picture4.jpg', ); is not work now.
Title: Re: Slideshow or Image rotator
Post by: Nathaniel on June 26, 2010, 03:15:56 AM
Try using the exact url for those images, like 'http://www.site.com/Big_set/b-picture1.jpg' instead of '/Big_set/b-picture1.jpg'. Make sure that the url for each image is correct. (you should be able to put that url into your browser and view the image with your browser)
Title: Re: Slideshow or Image rotator
Post by: Ares on January 08, 2011, 10:41:37 PM
could this code be change to get random images from a file basically set a file url not image url
Title: Re: Slideshow or Image rotator
Post by: andy on December 03, 2011, 02:03:53 AM
Think this would make a good feature addition. At the moment there are only old posts with bits of pieces of code and references to outside links and files. I had to spend quite a bit of time to find a php script that would rotate images in a block for me. Edits and php files in folders - better if an easier setup via a standard block with options.

Would be nice to see a standard block for this as it is a very common feature of websites. Not just for the front page but thats the main one people want to use images to attract people to stay on the site.

Almost all CMSs offer a variety of mods for this - Joomla, Wordpress etc, but not much for SMF and they dont look so good. One portal I think comes with what looks like a sliding front page image banner. Also as an introduction for pages with categories like Joomla K2.

Block with options for:

Folder the files are in.
Type of rotation - refresh or time interval.
Rotation effect (if easy to implement - simple swap, slide, fade etc)


Title: Re: Slideshow or Image rotator
Post by: teos on April 10, 2012, 10:24:52 AM
I know this is an old topic, but I use this block at my site  . How can I center the images ?
Any guidance will be highly appreciated.
Title: Re: Slideshow or Image rotator
Post by: andy on April 10, 2012, 11:13:23 AM
I use a php script for rotating images every time the page loads. You can find it in many locations on the internet - tiny portal, another smf portal also had an old topic about it.

Images go in a 'FOLDER-NAME' with the rotator.php script.
In the block all you need to do is this:
Code: [Select]
<p align="center"><img src="http://yourwebsite.com/FOLDER-NAME/rotate.php" alt="OCJ Photo" /></p>
The html  alignment tag centers everything.
There are settings that can be changed for the rotator - need to look for that. And there are many others out there you can try.
Title: Re: Slideshow or Image rotator
Post by: teos on April 10, 2012, 11:32:47 AM
Thanks igirisjin,
  Couldnt find the rotator.php ( tiny portal etc.) .  Can you pls attach the one you use ?
Title: Re: Slideshow or Image rotator
Post by: andy on April 10, 2012, 12:05:04 PM
TPortal was a topic about it but if you search online you will find the same one with the script.

Here is my copy but you may need to search online for the settings details.

Title: Re: Slideshow or Image rotator
Post by: teos on April 10, 2012, 12:32:54 PM
Thanks.  Download link is not  working at tportal.
Title: Re: Slideshow or Image rotator
Post by: AngelinaBelle on April 10, 2012, 01:06:56 PM
There is an article on it, and the download available, at marcofolio.net
http://www.marcofolio.net/webdesign/php_random_image_rotation.html
Title: Re: Slideshow or Image rotator
Post by: teos on April 10, 2012, 01:46:58 PM
Thanks for the info Angelinabelle,
 Actually, I need the code here, because without refreshing I need to show several images.
Only problem with this code is to center the images in the block.
Can you help ?
 
Title: Re: Slideshow or Image rotator
Post by: AngelinaBelle on April 10, 2012, 01:52:59 PM
The rotator only shows one image at a time.
How did you get it to show two?
What does your block look like now?
Title: Re: Slideshow or Image rotator
Post by: teos on April 10, 2012, 02:00:34 PM
I dont mean the rotate.php
I want to use the php code at the top of this topic. It does what I want. Only missing part is centering the image. Can you help ?
Title: Re: Slideshow or Image rotator
Post by: AngelinaBelle on April 10, 2012, 02:55:14 PM
There are several ways to center an image tag.
http://w3schools.com/html/default.asp (http://w3schools.com/html/default.asp)
http://w3schools.com/css/default.asp (http://w3schools.com/css/default.asp)

Here is one way you could do it:
http://lmgtfy.com/?q=center+img+tag (http://lmgtfy.com/?q=center+img+tag)
www.netmechanic.com/news/vol7/html_no10.htm (http://www.netmechanic.com/news/vol7/html_no10.htm)

Code: (find) [Select]
echo '
<img id="slideshow" src="" />
Code: (replace) [Select]
echo '
<img style="text-align:center;" id="slideshow" src="" />
Title: Re: Slideshow or Image rotator
Post by: teos on April 10, 2012, 03:19:23 PM
    Hoping that the solution you've provided will solve my problem, unfortunately no effect.
Cleared cache, refreshed browser. Tried with different browsers .. No :-(

Title: Re: Slideshow or Image rotator
Post by: AngelinaBelle on April 10, 2012, 03:42:35 PM
You could try surrounding it with <center><img ...... /> </center>
Title: Re: Slideshow or Image rotator
Post by: teos on April 10, 2012, 03:52:18 PM
Great!  worked this time :-)
Thanks alot AngelinaBelle, as always ...
Title: Re: Slideshow or Image rotator
Post by: Colton3310 on July 02, 2013, 02:43:35 AM
Hi, thanks all. The code may be useful, but I cannot understand it. Maybe you can use Kvisoft Image Slideshow Creator to do slideshows. It can also rotate.
Title: Re: Slideshow or Image rotator
Post by: ibirtual on August 24, 2013, 02:13:40 PM
hi there
 i want to add a link in any image .. is this posible ?
thanks in advance
Title: Re: Slideshow or Image rotator
Post by: [SiNaN] on August 25, 2013, 03:36:25 AM
Which exact code are you using? And can you elaborate what you want to do? Do you want to add links to the rotating images?
Title: Re: Slideshow or Image rotator
Post by: ibirtual on August 25, 2013, 05:01:11 AM
Hello

thanks for your reply

i use the code of this post, all work fine with the images  but yes i want to  add links to the rotating images

if this action posible ?

here is my code

Code: [Select]
$images = array(
    'image1.jpg',
    'image2.jpg',
    'image3.jpg',
    'image5.jpg',
);

$delay = 1;

$num_images = count($images);
echo '
<img id="slideshow" src="" />
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
    var images = [';

for ($i = 0; $i < $num_images; $i++)
    echo '["', $images[$i], '"]', ($i == $num_images - 1) ? '' : ',';
   
echo '];
    var current_image = 0;
    var num_images = ', $num_images, ';
    var timer;

    function changeImage()
    {
        if (current_image == num_images)
            current_image = 0;
        document.getElementById("slideshow").src = images[current_image];
        current_image = current_image + 1;
        var timer = setTimeout("changeImage();", ', $delay * 1000, ');
    }

    changeImage();
    // ]]></script>';
Title: Re: Slideshow or Image rotator
Post by: [SiNaN] on August 25, 2013, 06:06:10 AM
Try this:

Code: [Select]
$images = array(
'image1_url',
'image2_url',
'image3_url',
'image4_url',
);
$links = array(
'image1_link',
'image2_link',
'image3_link',
'image4_link',
);

$delay = 1;

$num_images = count($images);
echo '
<a id="slideshowa" href=""><img id="slideshowimg" src="" alt="" /></a>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var images = [';

for ($i = 0; $i < $num_images; $i++)
echo '["', $images[$i], '"]', ($i == $num_images - 1) ? '' : ',';

echo '];
var links = [';

for ($i = 0; $i < $num_images; $i++)
echo '["', $links[$i], '"]', ($i == $num_images - 1) ? '' : ',';

echo '];
var current_image = 0;
var num_images = ', $num_images, ';
var timer;

function changeImage()
{
if (current_image == num_images)
current_image = 0;
document.getElementById("slideshowimg").src = images[current_image];
document.getElementById("slideshowa").href = links[current_image];
current_image = current_image + 1;
var timer = setTimeout("changeImage();", ', $delay * 1000, ');
}

changeImage();
// ]]></script>';
Title: Re: Slideshow or Image rotator
Post by: ibirtual on August 25, 2013, 10:12:09 AM
Hello [SiNaN]

Thanks for the code

i try several times but is not posible for me to add the image and link

i see the image have a link but after click is direct to the image in big size

for example i want to link this image to this link

http://www.zonarave.com/forum/img/nop.jpg

http://www.zonarave.com/forum/index.php/board,48.0.html

can you try to include in the code please ?

to show me how look it

thanks again

Title: Re: Slideshow or Image rotator
Post by: ibirtual on August 25, 2013, 01:27:39 PM
i try this

Code: [Select]
$images = array(
'http://www.zonarave.com/forum/img/nop.jpg',
'image2_url',
'image3_url',
'image4_url',
);
$links = array(
        'http://www.zonarave.com/forum/index.php/board,48.0.html',
'image2_link',
'image3_link',
'image4_link',
);

$delay = 10;

$num_images = count($images);
echo '
<a id="slideshowa" href=""><img id="slideshowimg" src="" alt="" /></a>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var images = [';

for ($i = 0; $i < $num_images; $i++)
echo '["', $images[$i], '"]', ($i == $num_images - 1) ? '' : ',';

echo '];
var links = [';

for ($i = 0; $i < $num_images; $i++)
echo '["', $images[$i], '"]', ($i == $num_images - 1) ? '' : ',';

echo '];
var current_image = 0;
var num_images = ', $num_images, ';
var timer;

function changeImage()
{
if (current_image == num_images)
current_image = 0;
document.getElementById("slideshowimg").src = images[current_image];
document.getElementById("slideshowa").href = links[current_image];
current_image = current_image + 1;
var timer = setTimeout("changeImage();", ', $delay * 1000, ');
}

changeImage();
// ]]></script>';

and the link go to the image ...
Title: Re: Slideshow or Image rotator
Post by: [SiNaN] on August 26, 2013, 08:09:10 AM
Sorry. There was a mistake in my code. I've fixed it now. Can you try the code here again?:

http://simpleportal.net/index.php?topic=3592.msg63760#msg63760
Title: Re: Slideshow or Image rotator
Post by: ibirtual on August 26, 2013, 09:41:49 AM
 ;D
work perfect ¡¡

thanks for share and help

 :applause:

Title: Re: Slideshow or Image rotator
Post by: [SiNaN] on August 26, 2013, 09:58:00 AM
That's great to hear. You're welcome! :)
Title: Re: Slideshow or Image rotator
Post by: jtc442 on April 15, 2014, 08:43:13 PM
I hope I dont get in trouble for posting in this old of a post, but, I had a question. I used this PHP code and inserted it into a simple portal block. Added my pics, and the links to their sites, and all works great!! My question is, and I saw it mentioned above, but no solution for SINANS code. I just want to center my images. I have the portal block on the bottom of my forum, and all pics are aligned left. Will it be hard to add PHP code to center them? I can start a new thread if I need to.
Title: Re: Slideshow or Image rotator
Post by: Chen Zhen on April 15, 2014, 10:53:18 PM
jtc442,

  Edit the block and look to the bottom right where it has an input titled custom body class, put the following into that input: centertext
Title: Re: Slideshow or Image rotator
Post by: jtc442 on April 16, 2014, 09:17:23 AM
jtc442,

  Edit the block and look to the bottom right where it has an input titled custom body class, put the following into that input: centertext
Underdog, I appreciate the help! Wow, that was too easy. I am very new to this, but learning. I have never messed with those blocks before. I guess I need to learn more about all of that. Thanks a ton!!
Title: Re: Slideshow or Image rotator
Post by: AngelinaBelle on April 16, 2014, 12:09:17 PM
I am glad that everybody on this topic is learning and getting their site to do what they want it to do.

Please consider finding some nice online tutorials to make your learning process quicker and more fun.
I have found w3schools.com useful for HTML and CSS, but there are tons more tutorial sites out there.
Title: Re: Slideshow or Image rotator
Post by: jtc442 on April 16, 2014, 02:19:42 PM
I did search, very extensively. Looked at the sites you posted in post 21 as well. Nothing I tried worked, and with me being a total newbie at this and have just been learning as I go, I ran out of options other than to post here.

Little did I know that all I had to do was add that text to the box that underdog mentioned.

I will read up more on the links you posted and hopefully they will help me in the future. Thank you for your help as well!

(Im actually going to jump on right now and look at that site again)
Title: Re: Slideshow or Image rotator
Post by: Chen Zhen on April 16, 2014, 03:32:50 PM

  centertext is a common css class native only to SMF. Most SMF custom theme authors use this named class because mods use it for their display attributes. In other cases involving desired display it may be necessary to use direct container style attributes or create custom classes within a theme's css file. The resource that AngelinaBelle provided is very good for such things. I would also like to mention stackoverflow which is another great resource for all types of code.



Title: Re: Slideshow or Image rotator
Post by: AngelinaBelle on April 16, 2014, 06:56:02 PM
It is confusing and difficult at first, but you'll pick it up. 

Getting quick tips from others really does help.
I have worked with CSS a little bit, and I was completely surprised by a quick tip from [SiNaN] recently.
So there is a lot to learn.

Have fun!
Title: Re: Slideshow or Image rotator
Post by: jtc442 on April 17, 2014, 03:44:53 PM
I appreciate yalls support!! Thank you!
Title: Re: Slideshow or Image rotator
Post by: GamePersia on November 18, 2014, 08:22:12 AM
Try this:

Code: [Select]
$images = array(
'image1_url',
'image2_url',
'image3_url',
'image4_url',
);
$links = array(
'image1_link',
'image2_link',
'image3_link',
'image4_link',
);

$delay = 1;

$num_images = count($images);
echo '
<a id="slideshowa" href=""><img id="slideshowimg" src="" alt="" /></a>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
var images = [';

for ($i = 0; $i < $num_images; $i++)
echo '["', $images[$i], '"]', ($i == $num_images - 1) ? '' : ',';

echo '];
var links = [';

for ($i = 0; $i < $num_images; $i++)
echo '["', $links[$i], '"]', ($i == $num_images - 1) ? '' : ',';

echo '];
var current_image = 0;
var num_images = ', $num_images, ';
var timer;

function changeImage()
{
if (current_image == num_images)
current_image = 0;
document.getElementById("slideshowimg").src = images[current_image];
document.getElementById("slideshowa").href = links[current_image];
current_image = current_image + 1;
var timer = setTimeout("changeImage();", ', $delay * 1000, ');
}

changeImage();
// ]]></script>';

hi if i want to make default size of all images then how to do ? as if i put some different size image it not auto resize. kindly tell a way by which all images becomes of equal size and keep changing.  ;D
Title: Re: Slideshow or Image rotator
Post by: RandomRidoy on August 03, 2015, 01:22:38 AM
hi.

I want to modify my simpol portal to show recent posts only first  images.... image can be show in line by line or slide...

how can I do it please help...
Title: Re: Slideshow or Image rotator
Post by: [SiNaN] on August 03, 2015, 08:44:39 AM
Hello and welcome to SimplePortal!

Where are those images in the posts, if I may ask? Are those added inside the posts using the [img] tags or attachments?
Title: Re: Slideshow or Image rotator
Post by: RandomRidoy on August 20, 2015, 12:11:55 AM
hi.. how can i customize like this... they are using owl carosel for this and using [cover][/cover] code... can you please help me.....   

(http://i.imgur.com/4DWEnuv.png)
Title: Re: Slideshow or Image rotator
Post by: eldritch on August 22, 2015, 07:34:12 AM
Hi, I'm new here, I joined to ask some questions about the php script provided at the top of the topic.

Is it customisable like if I wanted to have links to some topics next to the images to refer to the posts they are taken from

would it be feasable and how ?

Thanks in advance.

Eric
SimplePortal 2.3.8 © 2008-2024, SimplePortal