<?php
// Thanks for this solution goes to Paul Phillips at http://wordpress.stackexchange.com/
// http://wordpress.stackexchange.com/questions/63707/automatically-replace-original-uploaded-image-with-large-image-size

add_image_size('new-original', 2500, 2500, false);
function replace_uploaded_image($image_data) {
	
	// If the image is smaller than our restrictions, do nothing
	if (!isset($image_data['sizes']['new-original'])) return $image_data;
	
	// paths to the uploaded image and the large image
	$upload_dir = wp_upload_dir();
	$uploaded_image_location = $upload_dir['basedir'] . '/' .$image_data['file'];
	$large_image_filename = $image_data['sizes']['new-original']['file'];
	
	// Do what wordpress does in image_downsize() ... just replace the filenames ;)
	$image_basename = wp_basename($uploaded_image_location);
	$large_image_location = str_replace($image_basename, $large_image_filename, $uploaded_image_location);
	
	// delete the uploaded image
	unlink($uploaded_image_location);
	
	// rename the large image
	rename($large_image_location, $uploaded_image_location);
	
	// update image metadata and return them
	$image_data['width'] = $image_data['sizes']['new-original']['width'];
	$image_data['height'] = $image_data['sizes']['new-original']['height'];
	unset($image_data['sizes']['new-original']);
	
	// Check if other size-configurations link to the large-file
	foreach($image_data['sizes'] as $size => $sizeData) {
		if ($sizeData['file'] === $large_image_filename)
			unset($image_data['sizes'][$size]);
	}

	return $image_data;
}
add_filter('wp_generate_attachment_metadata', 'replace_uploaded_image');
?>