Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm having issues using freshly uploaded images from the Media Uploader.

I'm using a custom uploader frame and some simple jQuery as seen here.

As you can see on line 49 I wish to grab the URLs of thumbnail sizes for selected images and display them on the page after selection.

The code works fine... for previously uploaded files selected from the Media Library.

However the attachment object (see console log on line 52) is returning an empty object with undefined sizes for freshly uploaded files. If I click around, closing and reopening the Media Upload frame I can get it to work, but for the purpose of a functional app, it's a failure.

I recorded this video to help understand what's going on.

I sincerely hope someone has at least a pointer to give me on this problem, because I've been trying to solve it for a while now without success.

share|improve this question
So turns out the media uploader throws an empty object into the list when uploading new files... an issue I had encountered and fixed in the code right above, and was the cause of problems for this purpose as well. I was able to solve my problem by adding an if statement to exclude that empty object: if( attachment.id != '' ) Although this solves my problem, I am still VERY curious as to why the media uploader includes an empty object before freshly uploaded media... – Adal Feb 13 at 6:59

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.