Image retrieval

  • SB
  • Moderator
  • Genius
  • User avatar
  • Posts: 8742
  • Loc: Aberdeen, Scotland

Post 3+ Months Ago

I guess my topic titles are pretty silly when it comes to light that i have no idea what i am actually going to start typing about.

Basically, i had hoped to have a website retrieving images from a folder when navigated on different page on the website. For an idea of what i am talking about a previous topic of mine may make things a bit clearer.

I am aware it is possible to randomise the image from a particular folder, however i had hoped that it wasn't random and infact the image would load up depending on the actual page that the site was on. I have a feeling that the code i was given by Spoof has probably covered most of what i need to know, however i am unaware of how to edit it and make it work the way i would like in this particular way.

If anyone can help me out here, or if you have a better suggestion for what i am hoping to achieve then i would love to hear from you.

Thank you.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • SB
  • Moderator
  • Genius
  • User avatar
  • Posts: 8742
  • Loc: Aberdeen, Scotland

Post 3+ Months Ago

anyone?
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

I would use the same basic concept as the code I provided. Create another set of classes that pointed to the particular images you wanted to show (Simply using the background attribute and a set given width and hight you can simulate an image).

For example:

CSS Code: [ Select ]
#image{
   background:#ECECEC;
   background-image: url(images/index.jpg);
   background-position:right;
   float:right;
   height: 312px;
   width: 740px;
}
  1. #image{
  2.    background:#ECECEC;
  3.    background-image: url(images/index.jpg);
  4.    background-position:right;
  5.    float:right;
  6.    height: 312px;
  7.    width: 740px;
  8. }


You could create classes that would only display the images.

Code: [ Select ]
#image{
    background:#ECECEC;
    
    float:right;
    height: 312px;
    width: 740px;
}
  1. #image{
  2.     background:#ECECEC;
  3.     
  4.     float:right;
  5.     height: 312px;
  6.     width: 740px;
  7. }


CSS Code: [ Select ]
.background1{
        background-image: url(images/bg1.jpg);
   background-position:right;
}
.background2{
        background-image: url(images/bg2.jpg);
   background-position:right;
}
.background3{
        background-image: url(images/bg3.jpg);
   background-position:right;
}
 
  1. .background1{
  2.         background-image: url(images/bg1.jpg);
  3.    background-position:right;
  4. }
  5. .background2{
  6.         background-image: url(images/bg2.jpg);
  7.    background-position:right;
  8. }
  9. .background3{
  10.         background-image: url(images/bg3.jpg);
  11.    background-position:right;
  12. }
  13.  


Then use the same concept to apply the style to what ever html element you need.

PHP Code: [ Select ]
$page_name = pathinfo($_SERVER['PHP_SELF']); // This will return the PHP file name of the current file
$page_name = $page_name['filename'];
$myPages_background = array(
  'pageName1'=>'background1',
  'pageName2'=>'background2',
  'pageName3'=>'background3'
    );
$use_style_background = $myPages_background[$page_name];
  1. $page_name = pathinfo($_SERVER['PHP_SELF']); // This will return the PHP file name of the current file
  2. $page_name = $page_name['filename'];
  3. $myPages_background = array(
  4.   'pageName1'=>'background1',
  5.   'pageName2'=>'background2',
  6.   'pageName3'=>'background3'
  7.     );
  8. $use_style_background = $myPages_background[$page_name];


Code: [ Select ]
<div id="image" class="<?php echo $use_style_background; ?>">
 <div align="right"></div>
</div>
  1. <div id="image" class="<?php echo $use_style_background; ?>">
  2.  <div align="right"></div>
  3. </div>
  • SB
  • Moderator
  • Genius
  • User avatar
  • Posts: 8742
  • Loc: Aberdeen, Scotland

Post 3+ Months Ago

I have finally got round to working on this a bit. Thanks for your help Spoof. Once again having some issues with it, but i have a feeling it was more because i was working on it at 11pm last night and i was completely shattered.

I will check it out later on and see what happens.

I appreciate your help Spoof.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 60 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.