/** * Some desc * * @since 1.0 * @access public * @param string * @return */ public function createCover($file, $inputName) { // Load our own image library $image = FD::image(); // Generates a unique name for this image. $name = $file['name']; // Load up the file. $image->load($file['tmp_name'], $name); // Ensure that the image is valid. if (!$image->isValid()) { // @TODO: Add some logging here. echo JText::_('PLG_FIELDS_AVATAR_VALIDATION_INVALID_IMAGE'); exit; } // Get the storage path $storage = SocialFieldsUserCoverHelper::getStoragePath($inputName); // Create a new avatar object. $photos = FD::get('Photos', $image); // Create avatars $sizes = $photos->create($storage); // We want to format the output to get the full absolute url. $base = basename($storage); $result = array(); foreach ($sizes as $size => $value) { $row = new stdClass(); $row->title = $file['name']; $row->file = $value; $row->path = JPATH_ROOT . '/media/com_easysocial/tmp/' . $base . '/' . $value; $row->uri = rtrim(JURI::root(), '/') . '/media/com_easysocial/tmp/' . $base . '/' . $value; $result[$size] = $row; } return $result; }
public function ajax_cover($file, $uname = 'cover_file') { /* $cls_obj = new SocialFieldsUserCover(); $cover_obj = $cls_obj->createCover($file,$uname); return $cover_obj; */ // Load our own image library $image = FD::image(); // Generates a unique name for this image. $name = $file['name']; // Load up the file. $image->load($file['tmp_name'], $name); // Ensure that the image is valid. if (!$image->isValid()) { return false; //need error code here } // Get the storage path $storage = SocialFieldsUserCoverHelper::getStoragePath($uname); // Create a new avatar object. $photos = FD::get('Photos', $image); // Create avatars $sizes = $photos->create($storage); // We want to format the output to get the full absolute url. $base = basename($storage); $result = array(); foreach ($sizes as $size => $value) { $row = new stdClass(); $row->title = $file['name']; $row->file = $value; $row->path = JPATH_ROOT . '/media/com_easysocial/tmp/' . $base . '/' . $value; $row->uri = rtrim(JURI::root(), '/') . '/media/com_easysocial/tmp/' . $base . '/' . $value; $result[$size] = $row; } return $result; }