Changeset 6617


Ignore:
Timestamp:
06/28/10 22:58:38 (9 years ago)
Author:
plg
Message:

merge r6616 from branch 2.1 to trunk

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:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_upload.inc.php

    r6498 r6617  
    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); 
  • trunk/admin/themes/default/template/photos_add_direct.tpl

    r6363 r6617  
    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.