Wordpress - Function to get URL of original uploaded image - full size
There are four valid sizes built in to the WordPress core.
the_post_thumbnail('thumbnail'); // Thumbnail (default 150px x 150px max)
the_post_thumbnail('medium'); // Medium resolution (default 300px x 300px max)
the_post_thumbnail('medium_large'); // Medium Large resolution (default 768px x 0(means automatic height by ratio) max) since WP version 4.4
the_post_thumbnail('large'); // Large resolution (default 640px x 640px max)
the_post_thumbnail('full'); // Original image resolution (unmodified)
The last is one you're looking for.
The following returns the URL.
<?php
$src = wp_get_attachment_image_src( $attachment_id, $size, $icon );
echo $src[0];
The whole code can look like that:
<?php
$src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full', false );
echo $src[0]; // the url of featured image
More information can be found here.
A bit late to the party,
but
get_the_post_thumbnail_url(null,'full');
does exactly the job, where full can be replaced by thumbnail, medium, medium_large or large.
For those who are coming here post October 2019
WordPress has introduced a "Big Image Threshold" since version 5.3 (Link)
In short all images above 2560px will be downscaled on upload. Calling the image format "full" will no longer always return the original untouched image but might return that 2560px version and will have '-scaled' in the url and path.
You can still get the url and path of the originally uploaded images with the following functions:
wp_get_original_image_path()
or wp_get_original_image_url()
.
Although the documentation suggests a new size "original_image"
was added, wp_get_attachment_image, wp_get_attachment_image_src or similar functions still return the scaled down version. So as far as I can tell no way to get the original file dimentions etc.