Log in | Register | Lost password

Bottom
upload image resize hack
  • Posted: 22.11.2005, 16:28
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    This hack will automatically resize images that were uploaded using an image upload field. Instead of creating only one thumbnail also the original image will be resized. So this can help you saving webspace:



    =========================
    changes in pnimageapi.php
    =========================

    insert after:

    Code

    $ok = pnModAPIFunc( 'pagesetter', 'image', 'createThumbnailFromGD',

    array('image' => $im,

    'thumbnailFilePath' => $args['thumbnailFilePath']) );

    the following code:

    Code

    $ok = pnModAPIFunc( 'pagesetter', 'image', 'createThumbnailFromGD',

    array('image' => $im,

    'thumbnailFilePath' => $args['imageFilePath'],

    'thumbnailsize' => 200) ); //define your imagesize here

    insert after:

    Code

    $thumbnailSize = pnModGetVar('pagesetter', 'thumbnailsize');

    $thumbnailSize = 100;

    the following code:

    Code

    if ($args['thumbnailsize'])

    {

    $thumbnailSize =$args['thumbnailsize'];

    }

    ======================
    changes in pneditapi
    ======================
    insert the following code:

    Code

    if ($fieldData)

    {

    $newfile=$uploadDir . '/' .$uploadFilename;

    $image_info = getImageSize($newfile) ;

    $uploadInfo['type']=$image_info['mime'];

    $uploadInfo['size']=filesize($newfile);

    $fieldData = $uploadInfo['type'] . '|' . $uploadInfo['size'] . '|' . $uploadFilename . '|' . $uploadInfo['name'];

    }


    after:

    Code

    $ok = pagesetterCreateThumbnail($uploadFilePath, $thumbnailFilePath, $uploadInfo['type']);

    if ($ok === false)

    return false;










    edited by: apollo13, Nov 22, 2005 - 05:32 PM
  • Posted: 09.10.2006, 10:41
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    We applied the changes for both files and it works so far. We tried to figure out where the upload size of the image is defined. We don't want to change all images, only that ones bigger then 450 px width or higth. Therefor we need the size of the upload image. Do you know, where it is defined.

Template courtesy of Designs By Darren.