If you upload an image to the media library via a URL, you sometimes get an error like this:
data is null
[Break on this error] $('#media-add-from-url-preview').html(data.preview);
I think the steps to reproduce are to hit the Submit button on the upload form directly after typing something in the URL field, without ever putting focus anywhere else first. The JavaScript is bound to the 'change' event, and tries to get JSON from the server when that is fired, so maybe the submit handler is causing the page to reload at the same time as the JSON is being printed and that confuses things, who knows.
This isn't a serious bug because I don't think it has any side effects - if you're submitting the form you wouldn't need to see a preview anyway. But I was asked to look into it nonetheless :) Maybe there is some other event we could bind to besides 'change', but for now, I just fixed it by putting in some basic error checking that prevents trying to insert data onto the page when the data doesn't exist.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | media-from-url.patch | 1.34 KB | james.elliott |
| media-upload-url-js-error.patch | 944 bytes | David_Rothstein |
Comments
Comment #1
james.elliott commentedNew patch. This is only half an implementation. There is no #media-add-from-url-preview element to add the preview to, so requesting it seems like an unneeded step.
I've just commented out the code for now, as well as fixing a variable declaration without the preceding "var"
Comment #3
effulgentsia commentedhttp://drupal.org/cvs?commit=414148
Comment #4
effulgentsia commentedIf someone decides to finish implementing the broken preview functionality that was commented out by this patch, please open a separate issue for that, but link to it from here. Thanks.