Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Link To Image script

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch

tandiono

Tandiono.comEstablished Member
Impact
0
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Is this something like what you're looking for?

PHP:
<?php
function link_image($img) {
$link_to_site = "http://www.yoursite.com";
$path_to_images = "http://www.yoursite.com/images/";
echo '<img src="'.$path_to_images.$img.'" /><br />
HTML Code:<br />
<input onclick="this.select();" value=\'<a href="'.$link_to_site.'"><img src="'.$path_to_images.$img.'" /></a>\'><br />
Direct Link:<br />
<input onclick="this.select();" value="'.$path_to_images.$img.'" /><br />
<br />';
}

link_image("test1.gif");
link_image("test2.gif");
link_image("test3.gif");
link_image("test4.gif");
link_image("test1.gif");
?>
 
0
Close
I guess something like this, but im not very familiar with php. can this code be insert into folder and get automatically link the rest of the images? Because i've hundreds of images in each folder. Thanks
 
0
Close
Here. This will automaticly generate code for all images in the /images/ folder.
PHP:
<?php
function link_image($img) {
$link_to_site = "http://www.yoursite.com";
$path_to_images = "http://www.yoursite.com/images/";
echo '<img src="'.$path_to_images.$img.'" /><br />
HTML Code:<br />
<input onclick="this.select();" value=\'<a href="'.$link_to_site.'"><img src="'.$path_to_images.$img.'" /></a>\'><br />
Direct Link:<br />
<input onclick="this.select();" value="'.$path_to_images.$img.'" /><br />
<br />';
}

if ($handle = opendir('./images/')) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != "..") {
           link_image($file);
       }
   }
   closedir($handle);
}
?>
 
0
Close
domain

Thanks for the script Jim, can you give me an instruction on how to use this script. As Im not very familiar on how this script works. But more or less I would like the script to be working as something like this :

http://www.myspaceimagecodes.com/glitter_words.php



I'll give away 1 domain for you :


sexirish.com Mon 11/07/2005 Tue 11/07/2006 - namecheap.com - free push


Looking forward to hear from you. Thanks :)
 
0
Close
Just stick the script I provided into a .php file.
Change the http://www.yoursite.com's near the top of the script to your domain.
Create a folder called images and upload your images there.
The script will open up the images folder and generate the code for them.
 
0
Close
I've change the it to this :

<?php
function link_image($img) {
$link_to_site = "http://www.xxx.com";
$path_to_images = "http://pic.xxx.com/pic/1";
echo '<img src="'.$path_to_images.$img.'" /><br />
HTML Code:<br />
<input onclick="this.select();" value=\'<a href="'.$link_to_site.'"><img src="'.$path_to_images.$img.'" /></a>\'><br />
Direct Link:<br />
<input onclick="this.select();" value="'.$path_to_images.$img.'" /><br />
<br />';
}

if ($handle = opendir('./images/')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
link_image($file);
}
}
closedir($handle);
}
?>


I save it to index.php and put it into /1/ folder.. But when i try to open it fail. Is there any thing that I need to do? Thanks
 
0
Close
Try this:
PHP:
<?php

function link_image($img)
{
  $link_to_site = "http://www.xxx.com";
  $path_to_images = "http://pic.xxx.com/1/";
  echo '<img src="'.$path_to_images.$img.'" /><br />
  HTML Code:<br />
  <input onclick="this.select();" value=\'<a href="'.$link_to_site.'"><img src="'.$path_to_images.$img.'" /></a>\'><br />
  Direct Link:<br />
  <input onclick="this.select();" value="'.$path_to_images.$img.'" /><br />
  <br />';
}

if($handle = opendir('.')) 
//I'm assuming that this 1/ folder contains the images, not /images/ folder
{
  while(false !== ($file = readdir($handle)))
  {
    if($file != "." && $file != ".." && $file != "Thumbs.db"/*pesky lil things*/)
    {
      link_image($file);
    }
  }
  closedir($handle);
}
?>
 
0
Close
works like a charm :) One last thing how can I integrate this script into .htm?

Because my main site is .htm and is there anyway to add google adsense on it? Thanks
 
0
Close
Well..to run a php script in .htm you could add this to your .htaccess:
Code:
AddType application/x-httpd-php .htm

Where do you want the adsense to show?
 
0
Close
SecondVersion said:
Well..to run a php script in .htm you could add this to your .htaccess:
Code:
AddType application/x-httpd-php .htm

Where do you want the adsense to show?

How can I call the .php from .htm files?

I've already add the code onto my .htaccess and as for the adsense im able to put it on the top and on the bottom but I can't manage to put it on the middle. Is there anyway? Thx
 
0
Close
tandiono said:
How can I call the .php from .htm files?

I've already add the code onto my .htaccess and as for the adsense im able to put it on the top and on the bottom but I can't manage to put it on the middle. Is there anyway? Thx
You'd do like you regularly would with .php files. .htm is parsed for any php code when that is added to .htaccess.
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back