public static function update_filename_extension($filename, $ext) {
		$ext = strtolower($ext);
		$ext = rtrim($ext, '.');
		$ext = ltrim($ext, '.');

		$filename_parts = explode('.', $filename);

		// Remove the old extension.
		if (count($filename_parts) > 1) {
			array_pop($filename_parts);
		}

		// Add the new extension.
		if (strlen($ext)) {
			$filename_parts[] = $ext;
		}

		return implode('.', $filename_parts);
	}