function resizeUploadedImage($image) { // Convert the YDFSFile objects to images if (is_object($image) && strtolower(get_class($image)) == 'ydfsfile') { $image = new YDFSImage($image->getAbsolutePath()); } // Convert strings to images if (is_string($image)) { $image = new YDFSImage($image); } // Get the maximum X and Y size $max_x = YDConfig::get('max_img_size_x', ''); $max_y = YDConfig::get('max_img_size_y', ''); $max_x = empty($max_x) ? 999999 : $max_x; $max_y = empty($max_y) ? 999999 : $max_y; // Do nothing if maximum sizes are specified if ($max_x == 99999 && $max_y == 999999) { return $image; } // Resize the image $image->saveThumbnail($max_x, $max_y, $image->getAbsolutePath()); // Return the image return $image; }
/** * If sending an HTML message with embedded images, use this function * to add the image. * * @param $file The image file path. * @param $c_type (optional) The content type of the image or file. * @param $name (optional) The filename of the image. */ function addHTMLImage($file, $c_type = '', $name = '') { if (!YDObjectUtil::isSubClass($file, 'YDFSImage')) { $file = new YDFSImage($file); } if (empty($name)) { $name = $file->getBaseName(); } if (empty($c_type)) { $c_type = $file->getMimeType(); } $this->_msg->AddEmbeddedImage($file->getAbsolutePath(), $name, $name, 'base64', $c_type); }