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.

Leave a Comment