/** * Creates a new image variation based on an existing image. * * @access public * @param null */ public function createVariation() { $ajax = EasyBlogHelper::getHelper('Ajax'); // The source of the original image $source = JRequest::getVar('path'); // The variation name. $variationName = JRequest::getVar('name'); // The variation's width. $width = JRequest::getVar('width'); // The variation's height. $height = JRequest::getVar('height'); // This let's us know the type of folder we should lookup to $place = JRequest::getString('place'); // @task: Let's test if the source item really exist. if (empty($variationName)) { return $ajax->fail(JText::_('COM_EASYBLOG_MM_PLEASE_ENTER_VARIATION_NAME')); } // @task: Let's test if the source item really exist. if (empty($width)) { return $ajax->fail(JText::_('COM_EASYBLOG_MM_PLEASE_ENTER_VARIATION_WIDTH')); } // @task: Let's test if the source item really exist. if (empty($height)) { return $ajax->fail(JText::_('COM_EASYBLOG_MM_PLEASE_ENTER_VARIATION_HEIGHT')); } // @task: Let's find the exact path first as there could be 3 possibilities here. // 1. Shared folder // 2. User folder $absolutePath = EasyBlogMediaManager::getAbsolutePath($source, $place); $absoluteURI = EasyBlogMediaManager::getAbsoluteURI($source, $place); // @task: Create the media object. $media = new EasyBlogMediaManager(); // @task: Let's test if the source item really exist. if (!$media->exists($absolutePath)) { return $ajax->fail(JText::_('COM_EASYBLOG_FILE_OR_FOLDER_DOES_NOT_EXIST')); } // @task: Let's try to create the variation here. $variationObj = $media->createVariation($absolutePath, $absoluteURI, $variationName, $width, $height, EBLOG_VARIATION_USER_TYPE); if (is_string($variationObj)) { return $ajax->fail($variationObj); } return $ajax->success($variationObj); }