This topic is locked

Image resizing and more

1/31/2007 5:08:21 PM
PHPRunner General questions
G
gje author

I have something that I want to do, but don't know how:

When an image is uploaded (in add and edit) I would like to:

  1. change the image name to the id of the record (e.g. id_th)
  2. create a 2nd version of that image resizing it to another size than the thumb (e.g. id_th2)
  3. delete the original image file
    Hope someone can help me out on this one!

J
Jane 2/1/2007

Hi,
you can do the following:

  1. turn on Thumbnails feature on the "Edit as" settings dialog on the Visual Editor tab.
  2. add AfterAdd event on the Events tab. Here is a sample code:
    function AfterAdd()

    {

    global $avalues;

    global $conn;

    //$avalues["File"]- your actual file name
    $str = "select mysql_insert_id() from TableName";

    $rs = db_query($str,$conn);

    $data = db_fetch_numarray($rs);
    //$data[0] - ID of the added record
    }



I would recommend you to learn some PHP so you can implement this on your own:

http://www.php.net/manual/en/