WordPress.org

Ready to get started?Download WordPress

Forums

image-size php script wont work with my theme (1 post)

  1. to_ul
    Member
    Posted 5 years ago #

    hi,
    when i paste this php-script into my single.php
    it won't work...
    why?...as standalone it works perfect

    <?php
    // File and new size
    $filename = 'http://www.multistorey.net/images/themselves2.jpg';
    $percent = 0.5;
    
    // Content type
    header('Content-type: image/jpeg');
    
    // Get new sizes
    list($width, $height) = getimagesize($filename);
    $newwidth = $width * $percent;
    $newheight = $height * $percent;
    
    // Load
    $thumb = imagecreatetruecolor($newwidth, $newheight);
    $source = imagecreatefromjpeg($filename);
    
    // Resize
    imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    
    // Output
    imagejpeg($thumb);
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic