Thumbnail problem

Started by denede, February 23, 2013, 10:40:45 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

denede

Tweaked with this :https://u-232-forum.duckdns.org/topic,467.0.html
Made it worked with my version, but on details i can't see the thumbnail, all i see is:

http://i.imgur.com/M4GOayk.png
the error is that the image contains errors.

when i click that, it redirects me to the picture.

on details i have
// ---------------------------------------------------------------- \\
    // ----------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD ----------- \\
    // ---------------------------------------------------------------- \\
    //require_once 'include/image_upload_settings.php';
    if ($IMAGE_UPLOAD_ENABLED) {

        $IMAGE_DIR = $IMAGE_MOD_SETTINGS['IMAGE_DIR'];
        $image_array = Get_Current_Images($id, $IMAGE_MOD_SETTINGS);

        // If images are found relating to the current torrent then display them
        if (!empty($image_array)) {
       
            $display_image_row = 0;
           
            foreach ($image_array as $img) {
                if ($img != 0) {
                    if ($display_image_row != 1) {
                        $display_image_row = 1;
                        $HTMLOUT .= "<tr><td style='vertical-align:top'>{$lang['details_images']}</td><td>";
                    }
                    $imgloc = $IMAGE_DIR . $img;
                    $HTMLOUT .= "<p><a href='$imgloc' title='<a href=getimage.php?file=$img>Download Image</a>'><img src='thumbnail.php?$img'></a></p>";
                }
            }
       
            if ($display_image_row == 1)
                $HTMLOUT .= "</td></tr>\n";
        }

    }
    // -------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD - END -------- \\


and this is the thumbnail file (i guess is a problem with the $img tag )

<?php

// ---------------------------------------------------------------- \\
// ----------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD ----------- \\
// ---------------------------------------------------------------- \\

//require_once "include/image_upload_settings.php";
require_once("include/bittorrent.php");
if (
$IMAGE_UPLOAD_ENABLED) {

    
$UPLOAD_DIRECTORY $IMAGE_MOD_SETTINGS['UPLOAD_DIRECTORY'];

    
# Constants
    
define("IMAGE_BASE"$UPLOAD_DIRECTORY);
    
define("MAX_WIDTH""300");
    
define("MAX_HEIGHT""300");

    
# Get image location
    
$image_file str_replace('..'''$_SERVER['QUERY_STRING']);
    
$image_path IMAGE_BASE "$image_file";

    
# Load image
    
$img null;
    
$ext strtolower(end(explode('.'$image_path)));
    if (
$ext == 'jpg' || $ext == 'jpeg') {
        
$img = @imagecreatefromjpeg($image_path);
    } else if (
$ext == 'png') {
        
$img = @imagecreatefrompng($image_path);
        
# Only if your version of GD includes GIF support
    
} else if ($ext == 'gif') {
        
$img = @imagecreatefromgif($image_path);
    }

    
# If an image was successfully loaded, test the image for size
    
if ($img) {

        
# Get image size and scale ratio
        
$width imagesx($img);
        
$height imagesy($img);
        
$scale min(MAX_WIDTH/$widthMAX_HEIGHT/$height);

        
# If the image is larger than the max shrink it
        
if ($scale 1) {
            
$new_width floor($scale*$width);
            
$new_height floor($scale*$height);

            
# Create a new temporary image
            
$tmp_img imagecreatetruecolor($new_width$new_height);

            
# Copy and resize old image into new image
            
imagecopyresized($tmp_img$img0000,
            
$new_width$new_height$width$height);
            
imagedestroy($img);
            
$img $tmp_img;
        }
    }

    
# Create error image if necessary
    
if (!$img) {
        
$img imagecreate(MAX_WIDTHMAX_HEIGHT);
        
imagecolorallocate($img,0,0,0);
        
$c imagecolorallocate($img,70,70,70);
        
imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c2);
        
imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c2);
    }

    
# Display the image
    
header("Content-type: image/jpeg");
    
imagejpeg($img);

}

// -------- POINDA'S "UPLOAD IMAGE WITH TORRENT" MOD - END -------- \\

?>