Changeset 6616


Ignore:
Timestamp:
Jun 28, 2010, 10:57:35 PM (14 years ago)
Author:
plg
Message:

bug 1701 fixed: support for PNG file in browser direct upload.

If the picture is a PNG file, then the "web size" picture is also a PNG file
but the thumbnail is always a JPEG file.

Location:
branches/2.1/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.1/admin/include/functions_upload.inc.php

    r6499 r6616  
    4343  $random_string = substr($md5sum, 0, 8);
    4444  $filename_wo_ext = $date_string.'-'.$random_string;
    45   $file_path = $upload_dir.'/'.$filename_wo_ext.'.jpg';
     45  $file_path = $upload_dir.'/'.$filename_wo_ext.'.';
     46
     47  list($width, $height, $type) = getimagesize($source_filepath);
     48  if (IMAGETYPE_PNG == $type)
     49  {
     50    $file_path.= 'png';
     51  }
     52  else
     53  {
     54    $file_path.= 'jpg';
     55  }
    4656
    4757  prepare_directory($upload_dir);
     
    199209  if (in_array($extension, array('jpg', 'jpeg')))
    200210  {
    201     $source_image = @imagecreatefromjpeg($source_filepath);
     211    $source_image = imagecreatefromjpeg($source_filepath);
    202212  }
    203213  else if ($extension == 'png')
    204214  {
    205     $source_image = @imagecreatefrompng($source_filepath);
     215    $source_image = imagecreatefrompng($source_filepath);
    206216  }
    207217  else
     
    253263    );
    254264 
    255   imagejpeg($destination_image, $destination_filepath, $quality);
     265  $extension = strtolower(get_extension($destination_filepath));
     266  if ($extension == 'png')
     267  {
     268    imagepng($destination_image, $destination_filepath);
     269  }
     270  else
     271  {
     272    imagejpeg($destination_image, $destination_filepath, $quality);
     273  }
    256274  // freeing memory ressources
    257275  imagedestroy($source_image);
  • branches/2.1/admin/themes/default/template/photos_add_direct.tpl

    r6364 r6616  
    107107    'buttonText'     : buttonText,
    108108    'multi'          : true,
    109     'fileDesc'       : 'Photo files (*.jpg,*.jpeg)',
    110     'fileExt'        : '*.jpg;*.JPG;*.jpeg;*.JPEG',
     109    'fileDesc'       : 'Photo files (*.jpg,*.jpeg,*.png)',
     110    'fileExt'        : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG',
    111111    'onAllComplete'  : function(event, data) {
    112112      if (data.errors) {
Note: See TracChangeset for help on using the changeset viewer.