this._uploadMatrix[$uploadID] = [];
for (var $i = 0; $i < $files.length; $i++) {
- this._uploadMatrix[$uploadID].push(this._initFile($files[$i]));
+ var $li = this._initFile($files[$i]);
+ $li.data('filename', $files[$i].name);
+ this._uploadMatrix[$uploadID].push($li);
$fd.append('__files[]', $files[$i]);
}
$fd.append('actionName', this._options.action);
$fd.append('className', this._className);
+ var $additionalParameters = this._getParameters();
+ for (var $name in $additionalParameters) {
+ $fd.append('parameters['+$name+']', $additionalParameters[$name]);
+ }
$.ajax({
type: 'POST',
data: $fd,
contentType: false,
processData: false,
- success: $.proxy(this._success, this),
+ success: function(data, textStatus, jqXHR) {
+ self._success($uploadID, data);
+ },
error: $.proxy(this._error, this),
xhr: function() {
var $xhr = $.ajaxSettings.xhr();
if ($xhr) {
$xhr.upload.addEventListener('progress', function(event) {
- self._progress(event, $uploadID);
+ self._progress($uploadID, event);
}, false);
}
return $xhr;
/**
* Callback for success event
*/
- _success: function(data, textStatus, jqXHR) {
- console.debug(jqXHR.responseText);
+ _success: function(uploadID, data) {
+ console.debug(data);
},
/**
/**
* Callback for progress event
*/
- _progress: function(event, uploadID) {
+ _progress: function(uploadID, event) {
var $percentComplete = Math.round(event.loaded * 100 / event.total);
for (var $i = 0; $i < this._uploadMatrix[uploadID].length; $i++) {
}
},
+ /**
+ * Returns additional parameters.
+ */
+ _getParameters: function() {
+ return {};
+ },
_initFile: function(file) {
var $li = $('<li>'+file.name+' ('+file.size+')<progress max="100"></progress></li>');
*/
public function createThumbnail($maxWidth, $maxHeight, $obtainDimensions = true) {
$width = $height = $x = $y = 0;
+ $sourceWidth = $this->width;
+ $sourceHeight = $this->height;
if ($obtainDimensions) {
if ($maxWidth / $this->width < $maxHeight / $this->height) {
else {
$width = $height = $maxWidth;
- if ($width > $height) {
- $x = ceil(($width - $height) / 2);
- $width = $height;
+ if ($sourceWidth > $sourceHeight) {
+ $x = ceil(($sourceWidth - $sourceHeight) / 2);
+ $sourceWidth = $sourceHeight;
}
else {
- $y = ceil(($height - $width) / 2);
- $height = $width;
+ $y = ceil(($sourceHeight - $sourceWidth) / 2);
+ $sourceHeight = $sourceWidth;
}
}
// resize image
$image = imageCreateTrueColor($width, $height);
imageAlphaBlending($image, false);
- imageCopyResampled($image, $this->image, 0, 0, $x, $y, $width, $height, $this->width, $this->height);
+ imageCopyResampled($image, $this->image, 0, 0, $x, $y, $width, $height, $sourceWidth, $sourceHeight);
imageSaveAlpha($image, true);
return $image;
* @return string
*/
public function getFilename() {
- return $this->name;
+ return $this->filename;
}
/**
public function getValidationErrorType() {
return $this->validationErrorType;
}
+
+ public function getImageData() {
+ if (strpos($this->getMimeType(), 'image/') == 0) {
+ if (($imageData = @getImageSize($this->getLocation())) !== false) {
+ return array(
+ 'width' => $imageData[0],
+ 'height' => $imageData[1],
+ 'mimeType' => $imageData['mime'],
+ );
+ }
+ }
+
+ return null;
+ }
}