Index: branches/5.1.x/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r13581 -r13658 --- branches/5.1.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 13581) +++ branches/5.1.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 13658) @@ -1,6 +1,6 @@ getObject( Array ('skip_autoload' => true)); + /* @var $object kDBItem */ + + $field = $this->Application->GetVar('field'); + $options = $object->GetFieldOptions($field); + if ($this->Application->GetVar('tmp')) { - $path = WRITEABLE . '/tmp/' . $this->Application->GetVar('id') . '_' . $this->Application->GetVar('file'); + $path = WRITEABLE . '/tmp/' . $this->Application->GetVar('id') . '_' . $file; } else { - $object =& $event->getObject(array('skip_autoload'=>true)); - $options = $object->GetFieldOptions($this->Application->GetVar('field')); + $upload_dir = $options['upload_dir']; - $path = FULL_PATH.$options['upload_dir'].$file; + if (array_key_exists('include_path', $options) && $options['include_path']) { + // relative path is already included in field + $upload_dir = ''; + } + + $path = FULL_PATH . $upload_dir . $file; } $path = str_replace('/', DIRECTORY_SEPARATOR, $path); @@ -2716,10 +2726,21 @@ exit; } + if ($this->Application->GetVar('thumb')) { + $image_helper =& $this->Application->recallObject('ImageHelper'); + /* @var $image_helper ImageHelper */ + + $path = $image_helper->ResizeImage($path, $options['thumb_format']); + + $base_url = rtrim($this->Application->BaseURL(), '/'); + $path = preg_replace('/^' . preg_quote($base_url, '/') . '(.*)/', FULL_PATH . '\\1', $path); + $path = str_replace('/', DIRECTORY_SEPARATOR, $path); + } + $type = mime_content_type($path); - header('Content-Length: '.filesize($path)); - header('Content-Type: '.$type); + header('Content-Length: ' . filesize($path)); + header('Content-Type: ' . $type); safeDefine('DBG_SKIP_REPORTING',1);