vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Design and Graphics Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=168)
-   -   Custom Banner Using Random Images and Graphic Overlay? (https://vborg.vbsupport.ru/showthread.php?t=222139)

SamirDarji 08-31-2009 08:49 AM

Custom Banner Using Random Images and Graphic Overlay?
 
I got this idea when I saw the random images at the top of www.dgrin.com and started seeing the dhtml/ajax popups that sites are now using.

Since it is possible to overlay graphics on top graphics with transparency, how hard would it be to overlay a graphic onto a series of images like at the top of www.dgrin.com ? Since you can use some sort of transparancy, you would have a completely dynamic banner that changes constantly.

This is what I'm set out to do, but I have no real experience in coding. I can figure out syntax and methods/functions and how to implement things, but I need almost an exact example for me to be able to reverse-engineer it and then use it for my purposes.

I've built a vbadvanced module which is basically just a table with the images just like www.dgrin.com. Now I need to figure out how to overlay my graphic over the table.

Any assistance or guidance appreciated.

SamirDarji 09-02-2009 05:03 PM

No one has any idea on how to do this? :confused:

Brother Malachi 09-02-2009 10:18 PM

Have you looked on dynamicdrive website? They might have something like this for you.
Actually, this isn't that hard using php. One way you can do it is using a php script that loads a random image. You make a directory and put all your images in there including the php script. Then you insert the php file as an image (ie <img src="/randomImages/random.php">) and it will load a random image for you each time. This makes it server side (doesn't rely on javascript) and you don't have to modify any vb php files. Below is the script.

PHP Code:

<?php
$folder 
'.';

$imgType = array();
$imgType['gif'] = 'image/gif';
$imgType['jpg'] = 'image/jpeg';
$imgType['jpeg'] = 'image/jpeg';
$imgType['png'] = 'image/png';

$img null;

if (
substr($folder,-1) != '/') {
    
$folder $folder.'/';
}

if (isset(
$_GET['img'])) {
    
$imageInfo pathinfo($_GET['img']);
    if (
        isset( 
$imgTypestrtolower$imageInfo['extension'] ) ] ) &&
        
file_exists$folder.$imageInfo['basename'] )
    ) {
        
$img $folder.$imageInfo['basename'];
    }
} else {
    
$fileList = array();
    
$handle opendir($folder);
    while ( 
false !== ( $file readdir($handle) ) ) {
        
$file_info pathinfo($file);
        if (
            isset( 
$imgTypestrtolower$file_info['extension'] ) ] )
        ) {
            
$fileList[] = $file;
        }
    }
    
closedir($handle);

    if (
count($fileList) > 0) {
        
$imageNumber time() % count($fileList);
        
$img $folder.$fileList[$imageNumber];
    }
}

if (
$img!=null) {
    
$imageInfo pathinfo($img);
    
$contentType 'Content-type: '.$imgType$imageInfo['extension'] ];
    
header ($contentType);
    
readfile($img);
} else {
    if ( 
function_exists('imagecreate') ) {
        
header ("Content-type: image/png");
        
$im = @imagecreate (100100)
            or die (
"Cannot initialize new GD image stream");
        
$background_color imagecolorallocate ($im255255255);
        
$text_color imagecolorallocate ($im0,0,0);
        
imagestring ($im255,  "IMAGE ERROR"$text_color);
        
imagepng ($im);
        
imagedestroy($im);
    }
}
?>


SamirDarji 09-03-2009 11:25 PM

The random file part I've already coded, but the code you've posted is interesting as I've been interested in writing a script for another purpose that returns not only the image, but a clickable image that can go to a link.

The hard part about this project is I don't know how to do an overlay of a graphic over the resulting table of graphics, which I've already got working. I've read enough to know it can be done with CSS and two divs, one overlaying on the other, but I don't know how to do that.

Brother Malachi 09-06-2009 01:06 AM

Quote:

Originally Posted by SamirDarji (Post 1879301)
The random file part I've already coded, but the code you've posted is interesting as I've been interested in writing a script for another purpose that returns not only the image, but a clickable image that can go to a link.

The hard part about this project is I don't know how to do an overlay of a graphic over the resulting table of graphics, which I've already got working. I've read enough to know it can be done with CSS and two divs, one overlaying on the other, but I don't know how to do that.

I'm confused...you can't return a clickable image using the php script.

SamirDarji 09-06-2009 02:38 AM

Quote:

Originally Posted by Brother Malachi (Post 1880375)
I'm confused...you can't return a clickable image using the php script.

That's true, you can't. But the script returns an image, which I didn't know how to do before. I can use that for another project I wanted to work on.


All times are GMT. The time now is 09:58 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06362 seconds
  • Memory Usage 1,752KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete