Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
pmj7  
#1 Posted : Friday, June 24, 2011 10:19:25 AM(UTC)
pmj7

Rank: Newbie

Groups: Member
Joined: 5/20/2011(UTC)
Posts: 3

Hi

I want to set things so that:

1. JPEG files

a. if less than 1000 pixels, just send the original

b. if greater than 1000 pixels, just send the resized file

2. Non-JPEG files, should just send the original file.

What I've found is that if I add a converter to produce a thumbnail of 1000 pixels, and I upload a MP4 file of 20 MB, it uploads two files for a total of 40MB. This is a massive waste of bandwidth.

How can I configure things so that I can upload a mix of JPEG and MP4 (and other movies) types at the same time, and just send up the resized (if necessary) JPEG file?

Thanks.

Peter

Dmitry.Obukhov  
#2 Posted : Sunday, June 26, 2011 11:27:37 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Peter,

To implement this feature, you should use two events:

1. BeforeUpload event where set three arrays (with type, width and height values of files added to upload list).

2. BeforePackageUpload event. Here you should iterate those arrays, and set necessary converters corresponded to conditions.

Here are the code snippets of the both events illustrating how to set converters according to file type and its width/height:

Code:

<script type="text/javascript">
var types = [];
var heights = [];
var widths = [];
function BeforeUpload(){
  count = $au.uploader('Uploader1').files().count();
  for (i = 0; i < count; i++){
    valueT = $au.uploader('Uploader1').files().get(i).type();
    types[i] = valueT;
    valueH = $au.uploader('Uploader1').files().get(i).height();
    heights[i] = valueH;
    valueW = $au.uploader('Uploader1').files().get(i).width();
    widths[i] = valueW;
  }
  k = 0;
}
			
function BeforePackageUpload(index){
  //check file type
  if (types.shift() == "JPG File"){
    //check file size
    if (widths[k] >= 1000 || heights[k] >= 1000){
      //set converter with thumbnail mode  
      $au.uploader('Uploader1').converters([{mode: "*.* = Thumbnail"}]); 
    }	
    else{
      //set converter with source file mode
      $au.uploader('Uploader1').converters([{mode: "*.* = SourceFile"}]); 
    }}
  else{
    //set converter with source file mode
    $au.uploader('Uploader1').converters([{mode: "*.* = SourceFile"}]);  
  }				
  k = k +1;
}
</script> 

Please try it out. If you have any additional questions or problems please let me know.

P.S. if you need to send JPG images and any video files, you will be able to set file mask for required file types:

Code:
 $uploader->getRestrictions()->setFileMask('*.jpg; *.jpeg; *.avi; *.mp4');

Edited by user Sunday, June 26, 2011 11:53:32 PM(UTC)  | Reason: Not specified

Best regards,

Dmitry Obukhov

Technical Support. Aurigma, Inc.

pmj7  
#3 Posted : Monday, June 27, 2011 8:43:12 AM(UTC)
pmj7

Rank: Newbie

Groups: Member
Joined: 5/20/2011(UTC)
Posts: 3

Hi

Not sure why you're doing types.shift instead of types[k]. This code does not work for me as the types do not come up as 'JPG File', for jpg and mp4 it always says 'Generic File'. This is on a Macintosh OS 10.6.8 (Java).

Peter

pmj7  
#4 Posted : Monday, June 27, 2011 1:39:05 PM(UTC)
pmj7

Rank: Newbie

Groups: Member
Joined: 5/20/2011(UTC)
Posts: 3

Hi

Ok, I'm using 'name' instead of 'type' as type always returns 'Generic File' for me (shows that way in the GUI too). I'm relying on the extension from the file name to see if it's a jpeg. Not foolproof.

I'm seeing an error that happens very frequently. This is from the Firefox console (as a single error). Refreshing the page makes it go away, but it happens nearly half the time in Safari and Firefox (Mac).

Error: uncaught exception: internal error: Can't get Java class name usingjava.lang.Class.getName()

Error: d.getConverterCount is not a function

Source File: .../aurigma/PHP/PHPClasses/ImageUploaderPHP/Scripts/aurigma.uploader.min.js

Line: 1

Peter

Edited by user Monday, June 27, 2011 1:40:01 PM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.