Answered by:
URL.createObjectURL fails in RP with thumbnails created by getThumbnailAsync

Question
-
systemThumbnailer = function(file, size) { return file.getThumbnailAsync(ThumbnailMode.singleItem, Math.max.apply(Math, size)).then(function(thumbnail) { return URL.createObjectURL(thumbnail, false).toUri(); }); };
This code works in the CP and fails with "TypeMismatch" in RP in the "URL.createObjectURL(thumbnail, false)" part. Why? Did not find anything about that in the migration doc.Friday, June 8, 2012 5:05 PM
Answers
-
Second param is now an object, which should be like this:
URL.createObjectURL(blob, {oneTimeOnly: false});
"Why? – The one-time-use URL was a non-standard extension to createObjectURL. We shared this concept with the rest of the W3C, and it has now been adopted into the File API. The W3C slightly changed our initial proposal to include this property bag in order to provide a more forward-looking solution. We are changing our implementation to conform to the W3C spec."
- Proposed as answer by Bryan Thomas Friday, June 8, 2012 5:20 PM
- Marked as answer by phil_ke Friday, June 8, 2012 5:24 PM
Friday, June 8, 2012 5:20 PM
All replies
-
Second param is now an object, which should be like this:
URL.createObjectURL(blob, {oneTimeOnly: false});
"Why? – The one-time-use URL was a non-standard extension to createObjectURL. We shared this concept with the rest of the W3C, and it has now been adopted into the File API. The W3C slightly changed our initial proposal to include this property bag in order to provide a more forward-looking solution. We are changing our implementation to conform to the W3C spec."
- Proposed as answer by Bryan Thomas Friday, June 8, 2012 5:20 PM
- Marked as answer by phil_ke Friday, June 8, 2012 5:24 PM
Friday, June 8, 2012 5:20 PM -
Great! Fixed and commited :)Friday, June 8, 2012 5:24 PM
-
This should actually be URL.createObjectURL(blob, {oneTimeOnly: true}); in order to match the code you had before where isResuable was set to false. Setting oneTimeOnly to true means that the URL and the thumbnail object will be released once it has been used, if it is set to false then you must manually call URL.revokeObjectURL when you're finished with it. Unless you need to use this URL in more than one <img> tag, you should always use {oneTimeOnly:true} to avoid leaking the thumbnail object.
Thursday, July 26, 2012 3:17 PM