/** * Saves the main image to the type, doing transformation work if configured to do so. * * @return boolean Indicating success. */ function _save_main_image() { $this->_current_tmpname = $this->_filter->create_tmp_copy($this->_original_tmpname); if (!$this->_filter->set_file($this->_current_tmpname)) { return false; } if (isset($this->_identifier)) { // we come from the image*s* type $blob_identifier = "{$this->_identifier}main"; $title = $this->_title; } else { $blob_identifier = 'main'; $title = $this->title; } $result = true; // Filter if necessary. if ($this->filter_chain && !$this->_filter->process_chain($this->filter_chain)) { $result = false; } if ($result) { if (array_key_exists('main', $this->_pending_attachments)) { unset($this->_pending_attachments['main']); $result = $this->update_attachment($blob_identifier, $this->_filename, $title, $this->_target_mimetype, $this->_current_tmpname, false); } else { $this->delete_attachment($blob_identifier); if (isset($this->_attachment_map)) { $this->_attachment_map[$blob_identifier] = array($this->_identifier, 'main'); } $result = $this->add_attachment($blob_identifier, $this->_filename, $title, $this->_target_mimetype, $this->_current_tmpname, false); } } @unlink($this->_current_tmpname); return $result; }