Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to select image from the WordPress 3.5 media uploader. I can get the image URL with the following code, but it gets the full size image. I want to get the thumbnail image url,how can I get that?

 var custom_uploader;
 $('.upload-image').click(function(e) {

        if (custom_uploader) {

        custom_uploader = wp.media.frames.file_frame = wp.media({
            title: 'Choose Image',
            button: {
                text: 'Choose Image'
            multiple: false

        //When a file is selected, grab the URL
        custom_uploader.on('select', function() {
            attachment = custom_uploader.state().get('selection').first().toJSON();
            var abc = attachment.url;    //this is full image url. 
            alert (abc);

share|improve this question

2 Answers 2

You can debug the result of attachment by :


and if the thumbnail size available you can retrieve it using :

 var thumb = attachment.sizes.thumbnail.url;
share|improve this answer

You'd have to make a call to the server to run some PHP.

$thumb_src = wp_get_attachment_image_src( $id, 'thumbnail' );

Where $id is the id of the attachment

attachment.attributes.id in your custom_uploader select function will give you the value. You could post that back with an ajax call and get the thumbnail url that way.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.