WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-22-2005, 04:14 PM
Jerry's Avatar
WebProWorld Pro
 

Join Date: Nov 2003
Location: Northern Texas
Posts: 259
Jerry RepRank 0
Default Help! thumbnail function not working properly

I have a function to generate thumbnail images. the function is working. Code is as follows:
Code:
<?php
function thumb($pic)
{
	//echo "function thumb running
";
	$image =  $pic;                
     $size = getimagesize("$image");
       $height = $size[1];
       $width = $size[0];
     if ($height > 150)
         {
               $height = 150;
               $percent = ($size[1] / $height);
               $width = round($size[0] / $percent);
         }
     else if ($width > 150)
         {
               $width = 150;
               $percent = ($size[0] / $width);
               $height = round($size[1] / $percent);
         }
     return '<img src=\"http://www.easystreet247.com/upload_files/$image\" height=\"$height\" width=\"$width\" >';
}
?>
The problem is that the image is not displaying when I call the function in code as follows:
Code:
$stuff0 = "<TR><td><table border=\"0\"><tr><td><a href=\"upload_files/$fullsize\" onclick=\"window.open(this.href); return false;\">thumb($thumbnail)</a>  </td><td></td>";
All that gets displayed is the name of the image as a hyperlink, instead of the image itself. I'm sure it's in the string settings, but I'm having a devil of a time figuring it out.

Can someone please help me with the string settings?
Reply With Quote
  #2 (permalink)  
Old 07-22-2005, 04:36 PM
WebProWorld New Member
 

Join Date: Jul 2005
Location: West Sussex
Posts: 6
Brewster RepRank 0
Default

Hi

Try this code:

Code:
$stuff0 = '<TR><td><table border="0"><tr><td>' . thumb($thumbnail) . '</td><td></td>';
Joe
Reply With Quote
  #3 (permalink)  
Old 07-22-2005, 04:44 PM
Jerry's Avatar
WebProWorld Pro
 

Join Date: Nov 2003
Location: Northern Texas
Posts: 259
Jerry RepRank 0
Default

much closer, except the function now returns:
Code:
<img src=\"http://www.easystreet247.com/upload_files/$image\" height=\"$height\" width=\"$width\" >
instead of a properly formatted image tag. I've tried a few variations in the function code, but nothing seems to be working.
Reply With Quote
  #4 (permalink)  
Old 07-22-2005, 05:23 PM
WebProWorld New Member
 

Join Date: Jul 2005
Location: West Sussex
Posts: 6
Brewster RepRank 0
Default

At least we're getting somewhere :)

Try this code for your function:

Code:
<?php
function thumb($pic)
{
   //echo "function thumb running
";
   $image =  $pic;               
     $size = getimagesize("$image");
       $height = $size[1];
       $width = $size[0];
     if ($height > 150)
         {
               $height = 150;
               $percent = ($size[1] / $height);
               $width = round($size[0] / $percent);
         }
     else if ($width > 150)
         {
               $width = 150;
               $percent = ($size[0] / $width);
               $height = round($size[1] / $percent);
         }
     return '';
}
?>
Joe
Reply With Quote
  #5 (permalink)  
Old 07-22-2005, 06:49 PM
Jerry's Avatar
WebProWorld Pro
 

Join Date: Nov 2003
Location: Northern Texas
Posts: 259
Jerry RepRank 0
Default

I got it working. The function code is as follows:
Code:
<?php
function thumb($pic)
{
	//echo "function thumb running
";
	$image =  $pic;                
     $size = getimagesize("upload_files/$image");
       $height = $size[1];
       $width = $size[0];
     if ($height > 100)
         {
               $height = 100;
               $percent = ($size[1] / $height);
               $width = round($size[0] / $percent);
         }
     else if ($width > 100)
         {
               $width = 100;
               $percent = ($size[0] / $width);
               $height = round($size[1] / $percent);
         }
     return '';
}
?>
Thanks for the help.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0